\input{preamble}

% OK, start here.
%
\begin{document}

\title{More on Morphisms}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
In this chapter we continue our study of properties of morphisms of schemes.
A fundamental reference is \cite{EGA}.






\section{Thickenings}
\label{section-thickenings}

\noindent
The following terminology may not be completely standard, but it is convenient.

\begin{definition}
\label{definition-thickening}
Thickenings.
\begin{enumerate}
\item We say a scheme $X'$ is a {\it thickening} of a scheme $X$ if
$X$ is a closed subscheme of $X'$ and the underlying topological spaces
are equal.
\item We say a scheme $X'$ is a {\it first order thickening} of a scheme $X$ if
$X$ is a closed subscheme of $X'$ and the quasi-coherent sheaf of ideals
$\mathcal{I} \subset \mathcal{O}_{X'}$ defining $X$ has square zero.
\item Given two thickenings $X \subset X'$ and $Y \subset Y'$ a
{\it morphism of thickenings} is a morphism $f' : X' \to Y'$ such that
$f'(X) \subset Y$, i.e., such that $f'|_X$ factors through the closed
subscheme $Y$. In this situation we set $f = f'|_X : X \to Y$ and we say
that $(f, f') : (X \subset X') \to (Y \subset Y')$ is a morphism of
thickenings.
\item Let $S$ be a scheme. We similarly define {\it thickenings over $S$}, and
{\it morphisms of thickenings over $S$}. This means that the schemes
$X, X', Y, Y'$ above are schemes over $S$, and that the morphisms
$X \to X'$, $Y \to Y'$ and $f' : X' \to Y'$ are morphisms over $S$.
\end{enumerate}
\end{definition}

\noindent
Finite order thickenings. Let $i_X : X \to X'$ be a thickening.
Any local section of the kernel
$\mathcal{I} = \Ker(i_X^\sharp)$ is locally nilpotent.
Let us say that $X \subset X'$ is a {\it finite order thickening}
if the ideal sheaf $\mathcal{I}$ is ``globally'' nilpotent, i.e.,
if there exists an $n \geq 0$ such that $\mathcal{I}^{n + 1} = 0$.
Technically the class of finite order thickenings $X \subset X'$
is much easier to handle than the general case.
Namely, in this case we have a filtration
$$
0 = \mathcal{I}^{n + 1} \subset
\mathcal{I}^n \subset
\mathcal{I}^{n - 1} \subset \ldots \subset
\mathcal{I} \subset \mathcal{O}_{X'}
$$
and we see that $X'$ is filtered by closed subspaces
$$
X = X_1 \subset X_2 \subset \ldots \subset X_n \subset X_{n + 1} = X'
$$
such that each pair $X_i \subset X_{i + 1}$ is a first order thickening
over $S$. Using simple induction arguments many results proved for first order
thickenings can be rephrased as results on finite order thickenings.

\medskip\noindent
First order thickening are described as follows (see
Modules, Lemma \ref{modules-lemma-double-structure-gives-derivation}).

\begin{lemma}
\label{lemma-first-order-thickening}
Let $X$ be a scheme over a base $S$. Consider a short exact sequence
$$
0 \to \mathcal{I} \to \mathcal{A} \to \mathcal{O}_X \to 0
$$
of sheaves on $X$ where $\mathcal{A}$ is a sheaf of
$f^{-1}\mathcal{O}_S$-algebras,
$\mathcal{A} \to \mathcal{O}_X$ is a surjection
of sheaves of $f^{-1}\mathcal{O}_S$-algebras, and $\mathcal{I}$ is its kernel.
If
\begin{enumerate}
\item $\mathcal{I}$ is an ideal of square zero in $\mathcal{A}$, and
\item $\mathcal{I}$ is quasi-coherent as an $\mathcal{O}_X$-module
\end{enumerate}
then $X' = (X, \mathcal{A})$ is a scheme and $X \to X'$ is a first
order thickening over $S$. Moreover, any first order thickening over
$S$ is of this form.
\end{lemma}

\begin{proof}
It is clear that $X'$ is a locally ringed space. Let $U = \Spec(B)$
be an affine open of $X$. Set $A = \Gamma(U, \mathcal{A})$. Note that
since $H^1(U, \mathcal{I}) = 0$ (see Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherent-affine-cohomology-zero})
the map $A \to B$ is surjective. By assumption the kernel
$I = \mathcal{I}(U)$ is an ideal of square zero in the ring $A$.
By
Schemes, Lemma \ref{schemes-lemma-morphism-into-affine}
there is a canonical morphism of locally ringed spaces
$$
(U, \mathcal{A}|_U) \longrightarrow \Spec(A)
$$
coming from the map $B \to \Gamma(U, \mathcal{A})$. Since this morphism
fits into the commutative diagram
$$
\xymatrix{
(U, \mathcal{O}_X|_U) \ar[d] \ar[r] & \Spec(B) \ar[d] \\
(U, \mathcal{A}|_U) \ar[r] & \Spec(A)
}
$$
we see that it is a homeomorphism on underlying topological spaces.
Thus to see that it is an isomorphism, it suffices to check it induces
an isomorphism on the local rings.
For $u \in U$ corresponding to the prime $\mathfrak p \subset A$
we obtain a commutative diagram of short exact sequences
$$
\xymatrix{
0 \ar[r] &
I_{\mathfrak p} \ar[r] \ar[d] &
A_{\mathfrak p} \ar[r] \ar[d] &
B_{\mathfrak p} \ar[r] \ar[d] & 0 \\
0 \ar[r] &
\mathcal{I}_u \ar[r] &
\mathcal{A}_u \ar[r] &
\mathcal{O}_{X, u} \ar[r] & 0.
}
$$
The left and right vertical arrows are isomorphisms because
$\mathcal{I}$ and $\mathcal{O}_X$ are quasi-coherent sheaves.
Hence also the middle map is an isomorphism. Hence every point
of $X' = (X, \mathcal{A})$ has an affine neighbourhood and $X'$ is a
scheme as desired.
\end{proof}

\begin{lemma}
\label{lemma-thickening-affine-scheme}
\begin{slogan}
Affineness is insensitive to thickenings
\end{slogan}
Any thickening of an affine scheme is affine.
\end{lemma}

\begin{proof}
This is a special case of
Limits, Proposition \ref{limits-proposition-affine}.
\end{proof}

\begin{proof}[Proof for a finite order thickening]
Suppose that $X \subset X'$ is a finite order thickening with $X$ affine. Then
we may use Serre's criterion to prove $X'$ is affine. More precisely, we will
use Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-compact-h1-zero-covering}. Let $\mathcal{F}$ be a
quasi-coherent $\mathcal{O}_{X'}$-module. It suffices to show that
$H^1(X', \mathcal{F}) = 0$. Denote $i : X \to X'$ the given closed immersion
and denote
$\mathcal{I} = \Ker(i^\sharp : \mathcal{O}_{X'} \to i_*\mathcal{O}_X)$.
By our discussion of finite order thickenings (following
Definition \ref{definition-thickening}) there exists an $n \geq 0$
and a filtration
$$
0 = \mathcal{F}_{n + 1} \subset \mathcal{F}_n \subset
\mathcal{F}_{n - 1} \subset \ldots \subset
\mathcal{F}_0 = \mathcal{F}
$$
by quasi-coherent submodules such that $\mathcal{F}_a/\mathcal{F}_{a + 1}$ is
annihilated by $\mathcal{I}$. Namely, we can take
$\mathcal{F}_a = \mathcal{I}^a\mathcal{F}$. Then
$\mathcal{F}_a/\mathcal{F}_{a + 1} = i_*\mathcal{G}_a$ for some quasi-coherent
$\mathcal{O}_X$-module $\mathcal{G}_a$, see Morphisms, Lemma
\ref{morphisms-lemma-i-star-equivalence}. We obtain
$$
H^1(X', \mathcal{F}_a/\mathcal{F}_{a + 1}) =
H^1(X', i_*\mathcal{G}_a) = H^1(X, \mathcal{G}_a) = 0
$$
The second equality comes from Cohomology of Schemes, Lemma
\ref{coherent-lemma-relative-affine-cohomology}
and the last equality from Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherent-affine-cohomology-zero}.
Thus $\mathcal{F}$ has a finite filtration whose successive quotients
have vanishing first cohomology and it follows by a simple
induction argument that $H^1(X', \mathcal{F}) = 0$.
\end{proof}

\begin{lemma}
\label{lemma-base-change-thickening}
Let $S \subset S'$ be a thickening of schemes. Let $X' \to S'$ be a morphism
and set $X = S \times_{S'} X'$. Then $(X \subset X') \to (S \subset S')$
is a morphism of thickenings. If $S \subset S'$ is a first
(resp.\ finite order) thickening, then $X \subset X'$ is a first
(resp.\ finite order) thickening.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-composition-thickening}
\begin{slogan}
Compositions of thickenings are thickenings
\end{slogan}
If $S \subset S'$ and $S' \subset S''$ are thickenings, then so is
$S \subset S''$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-descending-property-thickening}
The property of being a thickening is fpqc local.
Similarly for first order thickenings.
\end{lemma}

\begin{proof}
The statement means the following: Let $X \to X'$ be a morphism
of schemes and let $\{g_i : X'_i \to X'\}$
be an fpqc covering such that the base change $X_i \to X'_i$
is a thickening for all $i$. Then $X \to X'$ is a thickening.
Since the morphisms $g_i$ are jointly surjective we conclude
that $X \to X'$ is surjective. By
Descent, Lemma \ref{descent-lemma-descending-property-closed-immersion}
we conclude that $X \to X'$ is a closed immersion.
Thus $X \to X'$ is a thickening. We omit the proof in the
case of first order thickenings.
\end{proof}









\section{Morphisms of thickenings}
\label{section-morphisms-thickenings}

\noindent
If $(f, f') : (X \subset X') \to (Y \subset Y')$ is a morphism
of thickenings of schemes, then often properties of the morphism
$f$ are inherited by $f'$. There are several variants.

\begin{lemma}
\label{lemma-thicken-property-morphisms}
Let $(f, f') : (X \subset X') \to (S \subset S')$ be a morphism
of thickenings. Then
\begin{enumerate}
\item $f$ is an affine morphism if and only if $f'$ is an affine morphism,
\item $f$ is a surjective morphism if and only if $f'$ is a surjective morphism,
\item $f$ is quasi-compact if and only if $f'$ quasi-compact,
\item $f$ is universally closed if and only if $f'$ is universally closed,
\item $f$ is integral if and only if $f'$ is integral,
\item $f$ is (quasi-)separated if and only if $f'$ is (quasi-)separated,
\item $f$ is universally injective if and only if $f'$ is universally injective,
\item $f$ is universally open if and only if $f'$ is universally open,
\item $f$ is quasi-affine if and only if $f'$ is quasi-affine, and
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
Observe that $S \to S'$ and $X \to X'$ are universal homeomorphisms
(see for example
Morphisms, Lemma \ref{morphisms-lemma-reduction-universal-homeomorphism}).
This immediately implies parts (2), (3), (4), (7), and (8).
Part (1) follows from Lemma \ref{lemma-thickening-affine-scheme}
which tells us that there is a 1-to-1 correspondence between
affine opens of $S$ and $S'$ and between affine opens of $X$ and $X'$.
Part (9) follows from
Limits, Lemma \ref{limits-lemma-thickening-quasi-affine}
and the remark just made about affine opens of $S$ and $S'$.
Part (5) follows from (1) and (4) by
Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed}.
Finally, note that
$$
S \times_X S = S \times_{X'} S \to S \times_{X'} S' \to S' \times_{X'} S'
$$
is a thickening (the two arrows are thickenings by
Lemma \ref{lemma-base-change-thickening}).
Hence applying (3) and (4) to the morphism
$(S \subset S') \to (S \times_X S \to S' \times_{X'} S')$
we obtain (6).
\end{proof}

\begin{lemma}
\label{lemma-thicken-property-relatively-ample}
Let $(f, f') : (X \subset X') \to (S \subset S')$ be a morphism
of thickenings. Let $\mathcal{L}'$ be an invertible sheaf on $X'$
and denote $\mathcal{L}$ the restriction to $X$.
Then $\mathcal{L}'$ is $f'$-ample if and only if
$\mathcal{L}$ is $f$-ample.
\end{lemma}

\begin{proof}
Recall that being relatively ample is a condition for each
affine open in the base, see
Morphisms, Definition \ref{morphisms-definition-relatively-ample}.
By Lemma \ref{lemma-thickening-affine-scheme}
there is a 1-to-1 correspondence between
affine opens of $S$ and $S'$.
Thus we may assume $S$ and $S'$ are affine
and we reduce to proving that
$\mathcal{L}'$ is ample if and only if
$\mathcal{L}$ is ample.
This is Limits, Lemma \ref{limits-lemma-ample-on-reduction}.
\end{proof}

\begin{lemma}
\label{lemma-thicken-property-morphisms-cartesian}
Let $(f, f') : (X \subset X') \to (S \subset S')$ be a morphism
of thickenings such that $X = S \times_{S'} X'$. If $S \subset S'$
is a finite order thickening, then
\begin{enumerate}
\item $f$ is a closed immersion if and only if $f'$ is a closed immersion,
\item $f$ is locally of finite type if and only if $f'$ is
locally of finite type,
\item $f$ is locally quasi-finite if and only if $f'$ is locally
quasi-finite,
\item $f$ is locally of finite type of relative dimension $d$ if and
only if $f'$ is locally of finite type of relative dimension $d$,
\item $\Omega_{X/S} = 0$ if and only if $\Omega_{X'/S'} = 0$,
\item $f$ is unramified if and only if $f'$ is unramified,
\item $f$ is proper if and only if $f'$ is proper,
\item $f$ is finite if and only if $f'$ is finite,
\item $f$ is a monomorphism if and only if $f'$ is a monomorphism,
\item $f$ is an immersion if and only if $f'$ is an immersion, and
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
The properties $\mathcal{P}$ listed in the lemma are all stable
under base change, hence if $f'$ has property $\mathcal{P}$, then so
does $f$. See
Schemes, Lemmas \ref{schemes-lemma-base-change-immersion} and
\ref{schemes-lemma-base-change-monomorphism}
and
Morphisms, Lemmas
\ref{morphisms-lemma-base-change-finite-type},
\ref{morphisms-lemma-base-change-quasi-finite},
\ref{morphisms-lemma-base-change-relative-dimension-d},
\ref{morphisms-lemma-base-change-differentials},
\ref{morphisms-lemma-base-change-unramified},
\ref{morphisms-lemma-base-change-proper}, and
\ref{morphisms-lemma-base-change-finite}.

\medskip\noindent
The interesting direction in each case is therefore to assume
that $f$ has the property and deduce that $f'$ has it too.
By induction on the order of the thickening we may
assume that $S \subset S'$ is a first order thickening, see
discussion immediately following
Definition \ref{definition-thickening}.

\medskip\noindent
Most of the proofs will use a reduction to the affine case. Let
$U' \subset S'$ be an affine open and let $V' \subset X'$ be an affine open
lying over $U'$. Let $U' = \Spec(A')$ and denote $I \subset A'$ be the ideal
defining the closed subscheme $U' \cap S$. Say $V' = \Spec(B')$.
Then $V' \cap X = \Spec(B'/IB')$. Setting $A = A'/I$ and
$B = B'/IB'$ we get a commutative diagram
$$
\xymatrix{
0 \ar[r] &
IB' \ar[r] &
B' \ar[r] &
B \ar[r] & 0 \\
0 \ar[r] &
IA' \ar[r] \ar[u] &
A' \ar[r] \ar[u] &
A \ar[r] \ar[u] & 0
}
$$
with exact rows and $I^2 = 0$.

\medskip\noindent
The translation of (1) into algebra: If $A \to B$ is surjective,
then $A' \to B'$ is surjective. This follows from
Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}).

\medskip\noindent
The translation of (2) into algebra: If $A \to B$ is a finite type ring
map, then $A' \to B'$ is a finite type ring map. This follows from
Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK})
applied to a map $A'[x_1, \ldots, x_n] \to B'$ such that
$A[x_1, \ldots, x_n] \to B$ is surjective.

\medskip\noindent
Proof of (3).  Follows from (2) and that quasi-finiteness of a morphism
which is locally of finite type can be checked on fibres, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize}.

\medskip\noindent
Proof of (4). Follows from (2) and that the additional property of ``being of
relative dimension $d$'' can be checked on fibres (by definition, see
Morphisms, Definition \ref{morphisms-definition-relative-dimension-d}.

\medskip\noindent
The translation of (5) into algebra: If $\Omega_{B/A} = 0$, then
$\Omega_{B'/A'} = 0$. By
Algebra, Lemma \ref{algebra-lemma-differentials-base-change}
we have $0 = \Omega_{B/A} = \Omega_{B'/A'}/I\Omega_{B'/A'}$.
Hence $\Omega_{B'/A'} = 0$ by
Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}).

\medskip\noindent
The translation of (6) into algebra: If $A \to B$ is unramified
map, then $A' \to B'$ is unramified. Since $A \to B$ is of finite
type we see that $A' \to B'$ is of finite type by (2) above.
Since $A \to B$ is unramified we have $\Omega_{B/A} = 0$. By
part (5) we have $\Omega_{B'/A'} = 0$. Thus $A' \to B'$ is unramified.

\medskip\noindent
Proof of (7). Follows by combining (2) with
results of Lemma \ref{lemma-thicken-property-morphisms}
and the fact that proper equals quasi-compact $+$
separated $+$ locally of finite type $+$ universally closed.

\medskip\noindent
Proof of (8). Follows by combining (2) with
results of Lemma \ref{lemma-thicken-property-morphisms}
and using the fact that finite equals integral $+$ locally
of finite type (Morphisms, Lemma \ref{morphisms-lemma-finite-integral}).

\medskip\noindent
Proof of (9). As $f$ is a monomorphism we have $X = X \times_S X$.
We may apply the results proved so far to the morphism of thickenings
$(X \subset X') \to (X \times_S X \subset X' \times_{S'} X')$.
We conclude $X' \to X' \times_{S'} X'$ is a closed immersion by (1).
In fact, it is a first order thickening as the ideal defining the
closed immersion
$X' \to X' \times_{S'} X'$ is contained in the pullback of the ideal
$\mathcal{I} \subset \mathcal{O}_{S'}$ cutting out $S$ in $S'$.
Indeed, $X = X \times_S X = (X' \times_{S'} X') \times_{S'} S$
is contained in $X'$. Hence by
Morphisms, Lemma \ref{morphisms-lemma-differentials-diagonal}
it suffices to show that
$\Omega_{X'/S'} = 0$ which follows from (5)
and the corresponding statement for $X/S$.

\medskip\noindent
Proof of (10). If $f : X \to S$ is an immersion, then it factors as
$X \to U \to S$ where $U \to S$ is an open immersion and $X \to U$ is a
closed immersion. Let $U' \subset S'$ be the open subscheme whose
underlying topological space is the same as $U$. Then $X' \to S'$
factors through $U'$ and we conclude that $X' \to U'$ is a closed
immersion by part (1). This finishes the proof.
\end{proof}

\noindent
The following lemma is a variant on the preceding one. Rather than assume
that the thickenings involved are finite order (which allows us to transfer
the property of being locally of finite type from $f$ to $f'$),
we instead take as given that each of $f$ and $f'$ is locally of
finite type.

\begin{lemma}
\label{lemma-properties-that-extend-over-thickenings}
Let $(f, f') : (X \subset X') \to (Y \to Y')$ be a morphism
of thickenings. Assume $f$ and $f'$ are locally of finite type
and $X = Y \times_{Y'} X'$. Then
\begin{enumerate}
\item $f$ is locally quasi-finite if and only if $f'$ is locally quasi-finite,
\item $f$ is finite if and only if $f'$ is finite,
\item $f$ is a closed immersion if and only if $f'$ is a closed immersion,
\item $\Omega_{X/Y} = 0$ if and only if $\Omega_{X'/Y'} = 0$,
\item $f$ is unramified if and only if $f'$ is unramified,
\item $f$ is a monomorphism if and only if $f'$ is a monomorphism,
\item $f$ is an immersion if and only if $f'$ is an immersion,
\item $f$ is proper if and only if $f'$ is proper, and
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
The properties $\mathcal{P}$ listed in the lemma are all stable
under base change, hence if $f'$ has property $\mathcal{P}$, then so
does $f$. See
Schemes, Lemmas \ref{schemes-lemma-base-change-immersion} and
\ref{schemes-lemma-base-change-monomorphism}
and
Morphisms, Lemmas
\ref{morphisms-lemma-base-change-quasi-finite},
\ref{morphisms-lemma-base-change-relative-dimension-d},
\ref{morphisms-lemma-base-change-differentials},
\ref{morphisms-lemma-base-change-unramified},
\ref{morphisms-lemma-base-change-proper}, and
\ref{morphisms-lemma-base-change-finite}.
Hence in each case we need only to prove that if $f$ has
the desired property, so does $f'$.

\medskip\noindent
A morphism is locally quasi-finite if and only if it is locally
of finite type and the scheme theoretic fibres are discrete spaces, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-fibres}.
Since the underlying topological space is unchanged by 
passing to a thickening, we see that $f'$ is locally quasi-finite if
(and only if) $f$ is. This proves (1).

\medskip\noindent
Case (2) follows from case (5) of Lemma \ref{lemma-thicken-property-morphisms}
and the fact that the finite morphisms are precisely
the integral morphisms that are locally of finite type
(Morphisms, Lemma \ref{morphisms-lemma-finite-integral}).

\medskip\noindent
Case (3). This follows immediately from
Morphisms, Lemma \ref{morphisms-lemma-check-closed-infinitesimally}.

\medskip\noindent
Case (4) follows from the following algebra statement: Let $A$ be a ring and
let $I \subset A$ be a locally nilpotent ideal. Let $B$ be a finite type
$A$-algebra. If $\Omega_{(B/IB)/(A/I)} = 0$, then $\Omega_{B/A} = 0$.
Namely, the assumption means that $I\Omega_{B/A} = 0$, see
Algebra, Lemma \ref{algebra-lemma-differentials-base-change}.
On the other hand $\Omega_{B/A}$ is a finite $B$-module, see
Algebra, Lemma \ref{algebra-lemma-differentials-finitely-generated}.
Hence the vanishing of $\Omega_{B/A}$ follows from Nakayama's
lemma (Algebra, Lemma \ref{algebra-lemma-NAK}) and the fact
that $IB$ is contained in the Jacobson radical of $B$.

\medskip\noindent
Case (5) follows immediately from (4) and
Morphisms, Lemma \ref{morphisms-lemma-unramified-omega-zero}.

\medskip\noindent
Proof of (6). As $f$ is a monomorphism we have $X = X \times_Y X$.
We may apply the results proved so far to the morphism of thickenings
$(X \subset X') \to (X \times_Y X \subset X' \times_{Y'} X')$.
We conclude $\Delta_{X'/Y'} : X' \to X' \times_{Y'} X'$
is a closed immersion by (3). In fact $\Delta_{X'/Y'}$ is a bijection on
underlying sets, hence $\Delta_{X'/Y'}$ is a thickening. On the other hand
$\Delta_{X'/Y'}$ is locally of finite presentation by
Morphisms, Lemma \ref{morphisms-lemma-diagonal-morphism-finite-type}.
In other words, $\Delta_{X'/Y'}(X')$ is cut out by
a quasi-coherent sheaf of ideals
$\mathcal{J} \subset \mathcal{O}_{X' \times_{Y'} X'}$ of finite type.
Since $\Omega_{X'/Y'} = 0$ by (5) we see that
the conormal sheaf of $X' \to X' \times_{Y'} X'$ is zero by
Morphisms, Lemma \ref{morphisms-lemma-differentials-diagonal}.
In other words, $\mathcal{J}/\mathcal{J}^2 = 0$.
This implies $\Delta_{X'/Y'}$ is an isomorphism, for example
by Algebra, Lemma \ref{algebra-lemma-ideal-is-squared-union-connected}.

\medskip\noindent
Proof of (7). If $f : X \to Y$ is an immersion, then it factors as
$X \to V \to Y$ where $V \to Y$ is an open immersion and $X \to V$ is a
closed immersion. Let $V' \subset Y'$ be the open subscheme whose
underlying topological space is the same as $V$. Then $X' \to V'$
factors through $V'$ and we conclude that $X' \to V'$ is a closed
immersion by part (3).

\medskip\noindent
Case (8) follows from Lemma \ref{lemma-thicken-property-morphisms}
and the definition of proper morphisms as being the quasi-compact,
universally closed, and separated morphisms that are locally of finite type.
\end{proof}








\section{Picard groups of thickenings}
\label{section-picard-group-thickening}

\noindent
Some material on Picard groups of thickenings.

\begin{lemma}
\label{lemma-picard-group-first-order-thickening}
Let $X \subset X'$ be a first order thickening
with ideal sheaf $\mathcal{I}$. Then there is a canonical
exact sequence
$$
\xymatrix{
0 \ar[r] &
H^0(X, \mathcal{I}) \ar[r] &
H^0(X', \mathcal{O}_{X'}^*) \ar[r] &
H^0(X, \mathcal{O}^*_X) \ar `r[d] `d[l] `l[llld] `d[dll] [dll] \\
& H^1(X, \mathcal{I}) \ar[r] &
\Pic(X') \ar[r] &
\Pic(X) \ar `r[d] `d[l] `l[llld] `d[dll] [dll] \\
& H^2(X, \mathcal{I}) \ar[r] & \ldots \ar[r] & \ldots
}
$$
of abelian groups.
\end{lemma}

\begin{proof}
This is the long exact cohomology sequence associated to the
short exact sequence of sheaves of abelian groups
$$
0 \to \mathcal{I} \to \mathcal{O}_{X'}^* \to \mathcal{O}_X^* \to 0
$$
where the first map sends a local section $f$ of $\mathcal{I}$
to the invertible section $1 + f$ of $\mathcal{O}_{X'}$.
We also use the identification of the Picard group of a
ringed space with the first cohomology group of the sheaf
of invertible functions, see
Cohomology, Lemma \ref{cohomology-lemma-h1-invertible}.
\end{proof}

\begin{lemma}
\label{lemma-torsion-pic-thickening}
Let $X \subset X'$ be a thickening. Let $n$ be an integer
invertible in $\mathcal{O}_X$. Then the map
$\Pic(X')[n] \to \Pic(X)[n]$ is bijective.
\end{lemma}

\begin{proof}[Proof for a finite order thickening]
By the general principle explained following
Definition \ref{definition-thickening}
this reduces to the case of a first order thickening.
Then may use Lemma \ref{lemma-picard-group-first-order-thickening}
to see that it suffices to show that
$H^1(X, \mathcal{I})[n]$, $H^1(X, \mathcal{I})/n$, and
$H^2(X, \mathcal{I})[n]$ are zero.
This follows as multiplication by $n$ on $\mathcal{I}$
is an isomorphism as it is an $\mathcal{O}_X$-module.
\end{proof}

\begin{proof}[Proof in general]
Let $\mathcal{I} \subset \mathcal{O}_{X'}$ be the quasi-coherent ideal
sheaf cutting out $X$. Then we have a short exact sequence of
abelian groups
$$
0 \to (1 + \mathcal{I})^* \to \mathcal{O}_{X'}^* \to \mathcal{O}_X^* \to 0
$$
We obtain a long exact cohomology sequence as in the statement of
Lemma \ref{lemma-picard-group-first-order-thickening}
with $H^i(X, \mathcal{I})$ replaced by $H^i(X, (1 + \mathcal{I})^*)$.
Thus it suffices to show that raising to the $n$th power is an
isomorphism $(1 + \mathcal{I})^* \to (1 + \mathcal{I})^*$.
Taking sections over affine opens this follows from
Algebra, Lemma \ref{algebra-lemma-lift-nth-roots}.
\end{proof}





\section{First order infinitesimal neighbourhood}
\label{section-first-order-infinitesimal-neighbourhood}

\noindent
A natural construction of first order thickenings is the following.
Suppose that $i : Z \to X$ be an immersion of schemes. Choose an
open subscheme $U \subset X$ such that $i$ identifies $Z$ with a closed
subscheme $Z \subset U$. Let $\mathcal{I} \subset \mathcal{O}_U$ be the
quasi-coherent sheaf of ideals defining $Z$ in $U$. Then we can consider
the closed subscheme $Z' \subset U$ defined by the quasi-coherent sheaf
of ideals $\mathcal{I}^2$.

\begin{definition}
\label{definition-first-order-infinitesimal-neighbourhood}
Let $i : Z \to X$ be an immersion of schemes. The
{\it first order infinitesimal neighbourhood} of $Z$ in $X$ is
the first order thickening $Z \subset Z'$ over $X$ described above.
\end{definition}

\noindent
This thickening has the following universal property (which will assuage
any fears that the construction above depends on the choice of the open
$U$).

\begin{lemma}
\label{lemma-first-order-infinitesimal-neighbourhood}
Let $i : Z \to X$ be an immersion of schemes. The first order infinitesimal
neighbourhood $Z'$ of $Z$ in $X$ has the following universal property:
Given any commutative diagram
$$
\xymatrix{
Z \ar[d]_i & T \ar[l]^a \ar[d] \\
X & T' \ar[l]_b
}
$$
where $T \subset T'$ is a first order thickening over $X$, there exists
a unique morphism $(a', a) : (T \subset T') \to (Z \subset Z')$ of
thickenings over $X$.
\end{lemma}

\begin{proof}
Let $U \subset X$ be the open used in the construction of $Z'$, i.e., an
open such that $Z$ is identified with a closed subscheme of $U$ cut out by
the quasi-coherent sheaf of ideals $\mathcal{I}$.
Since $|T| = |T'|$ we see that $b(T') \subset U$. Hence we can
think of $b$ as a morphism into $U$. Let $\mathcal{J} \subset \mathcal{O}_{T'}$
be the ideal cutting out $T$. Since $b(T) \subset Z$ by the diagram above
we see that $b^\sharp(b^{-1}\mathcal{I}) \subset \mathcal{J}$. As
$T'$ is a first order thickening of $T$ we see that $\mathcal{J}^2 = 0$
hence $b^\sharp(b^{-1}(\mathcal{I}^2)) = 0$. By
Schemes, Lemma \ref{schemes-lemma-characterize-closed-subspace}
this implies that $b$ factors through $Z'$. Denote $a' : T' \to Z'$
this factorization and everything is clear.
\end{proof}

\begin{lemma}
\label{lemma-infinitesimal-neighbourhood-conormal}
Let $i : Z \to X$ be an immersion of schemes. Let $Z \subset Z'$ be
the first order infinitesimal neighbourhood of $Z$ in $X$.
Then the diagram
$$
\xymatrix{
Z \ar[r] \ar[d] & Z' \ar[d] \\
Z \ar[r] & X
}
$$
induces a map of conormal sheaves $\mathcal{C}_{Z/X} \to \mathcal{C}_{Z/Z'}$ by
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial}.
This map is an isomorphism.
\end{lemma}

\begin{proof}
This is clear from the construction of $Z'$ above.
\end{proof}
















\section{Formally unramified morphisms}
\label{section-formally-unramified}

\noindent
Recall that a ring map $R \to A$ is called {\it formally unramified}
(see Algebra, Definition \ref{algebra-definition-formally-unramified})
if for every commutative solid diagram
$$
\xymatrix{
A \ar[r] \ar@{-->}[rd] & B/I \\
R \ar[r] \ar[u] & B \ar[u]
}
$$
where $I \subset B$ is an ideal of square zero, at most one dotted
arrow exists which makes the diagram commute. This motivates
the following analogue for morphisms of schemes.

\begin{definition}
\label{definition-formally-unramified}
Let $f : X \to S$ be a morphism of schemes.
We say $f$ is {\it formally unramified} if given any solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l] \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
where $T \subset T'$ is a first order thickening of affine schemes over $S$
there exists at most one dotted arrow making the diagram commute.
\end{definition}

\noindent
We first prove some formal lemmas, i.e., lemmas which can be proved by
drawing the corresponding diagrams.

\begin{lemma}
\label{lemma-formally-unramified-not-affine}
If $f : X \to S$ is a formally unramified morphism, then given
any solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l] \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
where $T \subset T'$ is a first order thickening of schemes over $S$
there exists at most one dotted arrow making the diagram commute.
In other words, in
Definition \ref{definition-formally-unramified}
the condition that $T$ be affine may be dropped.
\end{lemma}

\begin{proof}
This is true because a morphism is determined by its restrictions
to affine opens.
\end{proof}

\begin{lemma}
\label{lemma-composition-formally-unramified}
A composition of formally unramified morphisms is formally unramified.
\end{lemma}

\begin{proof}
This is formal.
\end{proof}

\begin{lemma}
\label{lemma-base-change-formally-unramified}
A base change of a formally unramified morphism is formally unramified.
\end{lemma}

\begin{proof}
This is formal.
\end{proof}

\begin{lemma}
\label{lemma-formally-unramified-on-opens}
Let $f : X \to S$ be a morphism of schemes.
Let $U \subset X$ and $V \subset S$ be open such that
$f(U) \subset V$. If $f$ is formally unramified, so is $f|_U : U \to V$.
\end{lemma}

\begin{proof}
Consider a solid diagram
$$
\xymatrix{
U \ar[d]_{f|_U} & T \ar[d]^i \ar[l]^a \\
V & T' \ar[l] \ar@{-->}[lu]
}
$$
as in Definition \ref{definition-formally-unramified}. If $f$ is formally
ramified, then there exists at most one
$S$-morphism $a' : T' \to X$ such that $a'|_T = a$.
Hence clearly there exists at most one such morphism into $U$.
\end{proof}

\begin{lemma}
\label{lemma-affine-formally-unramified}
Let $f : X \to S$ be a morphism of schemes.
Assume $X$ and $S$ are affine.
Then $f$ is formally unramified if and only if
$\mathcal{O}_S(S) \to \mathcal{O}_X(X)$ is a formally unramified
ring map.
\end{lemma}

\begin{proof}
This is immediate from the definitions
(Definition \ref{definition-formally-unramified} and
Algebra, Definition \ref{algebra-definition-formally-unramified})
by the equivalence of categories of rings and affine schemes,
see
Schemes, Lemma \ref{schemes-lemma-category-affine-schemes}.
\end{proof}

\noindent
Here is a characterization in terms of the sheaf of differentials.

\begin{lemma}
\label{lemma-formally-unramified-differentials}
Let $f : X \to S$ be a morphism of schemes.
Then $f$ is formally unramified if and only if $\Omega_{X/S} = 0$.
\end{lemma}

\begin{proof}
We recall some of the arguments of the proof of
Morphisms, Lemma \ref{morphisms-lemma-differentials-affine}.
Let $W \subset X \times_S X$ be an open such that
$\Delta : X \to X \times_S X$ induces a closed immersion into $W$.
Let $\mathcal{J} \subset \mathcal{O}_W$ be the ideal sheaf of this
closed immersion. Let $X' \subset W$ be the closed subscheme
defined by the quasi-coherent sheaf of ideals $\mathcal{J}^2$.
Consider the two morphisms $p_1, p_2 : X' \to X$ induced by
the two projections $X \times_S X \to X$.
Note that $p_1$ and $p_2$ agree when composed with $\Delta : X \to X'$
and that $X \to X'$ is a closed immersion defined by a an ideal
whose square is zero. Moreover there is a short exact sequence
$$
0 \to \mathcal{J}/\mathcal{J}^2 \to \mathcal{O}_{X'} \to \mathcal{O}_X \to 0
$$
and $\Omega_{X/S} = \mathcal{J}/\mathcal{J}^2$. Moreover,
$\mathcal{J}/\mathcal{J}^2$ is generated by the local
sections $p_1^\sharp(f) - p_2^\sharp(f)$ for $f$ a local section of
$\mathcal{O}_X$.

\medskip\noindent
Suppose that $f : X \to S$ is formally unramified.
By assumption this means that $p_1 = p_2$ when restricted to any
affine open $T' \subset X'$. Hence $p_1 = p_2$. By what was said above
we conclude that $\Omega_{X/S} = \mathcal{J}/\mathcal{J}^2 = 0$.

\medskip\noindent
Conversely, suppose that $\Omega_{X/S} = 0$. Then $X' = X$. Take any pair
of morphisms $f'_1, f'_2 : T' \to X$ fitting as dotted arrows in
the diagram of
Definition \ref{definition-formally-unramified}.
This gives a morphism $(f'_1, f'_2) : T' \to X \times_S X$.
Since $f'_1|_T = f'_2|_T$ and $|T| =|T'|$ we see that the image of $T'$
under $(f'_1, f'_2)$ is contained in the open $W$ chosen above. Since
$(f'_1, f'_2)(T) \subset \Delta(X)$ and since $T$ is defined by an ideal
of square zero in $T'$ we see that $(f'_1, f'_2)$ factors through $X'$.
As $X' = X$ we conclude $f_1' = f'_2$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-unramified-formally-unramified}
\begin{slogan}
Unramified morphisms are the same as formally unramified morphism that
are locally of finite type.
\end{slogan}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item The morphism $f$ is unramified (resp.\ G-unramified), and
\item the morphism $f$ is locally of finite type (resp.\ locally of finite
presentation) and formally unramified.
\end{enumerate}
\end{lemma}

\begin{proof}
Use Lemma \ref{lemma-formally-unramified-differentials} and
Morphisms, Lemma \ref{morphisms-lemma-unramified-omega-zero}.
\end{proof}









\section{Universal first order thickenings}
\label{section-universal-thickening}

\noindent
Let $h : Z \to X$ be a morphism of schemes. A {\it universal first order
thickening} of $Z$ over $X$ is a first order thickening $Z \subset Z'$
over $X$ such that given any first order thickening $T \subset T'$
over $X$ and a solid commutative diagram
$$
\xymatrix{
& Z \ar[ld] & & T \ar[rd] \ar[ll]^a \\
Z' \ar[rrd] & & & & T' \ar@{..>}[llll]_{a'} \ar[lld]^b \\
 & & X
}
$$
there exists a unique dotted arrow making the diagram commute.
Note that in this situation $(a, a') : (T \subset T') \to (Z \subset Z')$
is a morphism of thickenings over $X$. Thus if a universal first order
thickening exists, then it is unique up to unique isomorphism.
In general a universal first order thickening
does not exist, but if $h$ is formally unramified then it does.

\begin{lemma}
\label{lemma-universal-thickening}
Let $h : Z \to X$ be a formally unramified morphism of schemes.
There exists a universal first order thickening $Z \subset Z'$ of
$Z$ over $X$.
\end{lemma}

\begin{proof}
During this proof we will say $Z \subset Z'$ is a universal first order
thickening of $Z$ over $X$ if it satisfies the condition of the lemma.
We will construct the universal first order thickening $Z \subset Z'$ over $X$
by glueing, starting with the affine case which is
Algebra, Lemma \ref{algebra-lemma-universal-thickening}.
We begin with some general remarks.

\medskip\noindent
If a universal first order thickening of $Z$ over $X$ exists, then it is unique
up to unique isomorphism. Moreover, suppose that $V \subset Z$ and
$U \subset X$ are open subschemes such that $h(V) \subset U$. Let
$Z \subset Z'$ be a universal first order thickening of $Z$ over $X$.
Let $V' \subset Z'$ be the open subscheme such that $V = Z \cap V'$.
Then we claim that $V \subset V'$ is the universal first order thickening of
$V$ over $U$. Namely, suppose given any diagram
$$
\xymatrix{
V \ar[d]_h & T \ar[l]^a \ar[d] \\
U & T' \ar[l]_b
}
$$
where $T \subset T'$ is a first order thickening over $U$. By the universal
property of $Z'$ we obtain $(a, a') : (T \subset T') \to (Z \subset Z')$.
But since we have equality $|T| = |T'|$ of underlying topological spaces
we see that $a'(T') \subset V'$. Hence we may think of $(a, a')$
as a morphism of thickenings $(a, a') : (T \subset T') \to (V \subset V')$
over $U$. Uniqueness is clear also. In a completely similar manner one proves
that if $h(Z) \subset U$ and $Z \subset Z'$ is a universal first order
thickening over $U$, then $Z \subset Z'$ is a universal first order thickening
over $X$.

\medskip\noindent
Before we glue affine pieces let us show that the lemma holds if
$Z$ and $X$ are affine. Say $X = \Spec(R)$ and $Z = \Spec(S)$. By
Algebra, Lemma \ref{algebra-lemma-universal-thickening}
there exists a first order thickening $Z \subset Z'$ over $X$
which has the universal property of the lemma for diagrams
$$
\xymatrix{
Z \ar[d]_h & T \ar[l]^a \ar[d] \\
X & T' \ar[l]_b
}
$$
where $T, T'$ are affine. Given a general diagram we can choose an affine
open covering $T' = \bigcup T'_i$ and we obtain morphisms
$a'_i : T'_i \to Z'$ over $X$ such that $a'_i|_{T_i} = a|_{T_i}$.
By uniqueness we see that $a'_i$ and $a'_j$ agree on any affine open
of $T'_i \cap T'_j$. Hence the morphisms $a'_i$ glue to a global morphism
$a' : T' \to Z'$ over $X$ as desired. Thus the lemma holds if $X$ and $Z$
are affine.

\medskip\noindent
Choose an affine open covering $Z = \bigcup Z_i$ such that each $Z_i$
maps into an affine open $U_i$ of $X$. By
Lemma \ref{lemma-formally-unramified-on-opens}
the morphisms $Z_i \to U_i$ are formally unramified.
Hence by the affine case we obtain universal first order thickenings
$Z_i \subset Z_i'$ over $U_i$. By the general remarks above
$Z_i \subset Z_i'$ is also a universal first order thickening of
$Z_i$ over $X$. Let $Z'_{i, j} \subset Z'_i$ be the open subscheme
such that $Z_i \cap Z_j = Z'_{i, j} \cap Z_i$. By the general remarks
we see that both $Z'_{i, j}$ and $Z'_{j, i}$ are universal first
order thickenings of $Z_i \cap Z_j$ over $X$. Thus, by
the first of our general remarks, we see that there is a canonical isomorphism
$\varphi_{ij} : Z'_{i, j} \to Z'_{j, i}$ inducing the identity on
$Z_i \cap Z_j$. We claim that these morphisms satisfy the cocycle condition of
Schemes, Section \ref{schemes-section-glueing-schemes}.
(Verification omitted. Hint: Use that $Z'_{i, j} \cap Z'_{i, k}$ is the
universal first order thickening of $Z_i \cap Z_j \cap Z_k$ which determines
it up to unique isomorphism by what was said above.)
Hence we can use the results of
Schemes, Section \ref{schemes-section-glueing-schemes}
to get a first order thickening $Z \subset Z'$ over $X$ which the property
that the open subscheme $Z'_i \subset Z'$ with $Z_i = Z'_i \cap Z$
is a universal first order thickening of $Z_i$ over $X$.

\medskip\noindent
It turns out that this implies formally that $Z'$ is a universal first order
thickening of $Z$ over $X$. Namely, we have the universal property for any
diagram
$$
\xymatrix{
Z \ar[d]_h & T \ar[l]^a \ar[d] \\
X & T' \ar[l]_b
}
$$
where $a(T)$ is contained in some $Z_i$. Given a general diagram we can
choose an open covering $T' = \bigcup T'_i$ such that $a(T_i) \subset Z_i$.
We obtain morphisms $a'_i : T'_i \to Z'$ over $X$ such that
$a'_i|_{T_i} = a|_{T_i}$. We see that $a'_i$ and $a'_j$ necessarily agree
on $T'_i \cap T'_j$ since both $a'_i|_{T'_i \cap T'_j}$ and
$a'_j|_{T'_i \cap T'_j}$ are solutions of the problem of mapping into the
universal first order thickening $Z'_i \cap Z'_j$ of $Z_i \cap Z_j$ over $X$.
Hence the morphisms $a'_i$ glue to a global morphism
$a' : T' \to Z'$ over $X$ as desired. This finishes the proof.
\end{proof}

\begin{definition}
\label{definition-universal-thickening}
Let $h : Z \to X$ be a formally unramified morphism of schemes.
\begin{enumerate}
\item The {\it universal first order thickening} of $Z$ over $X$
is the thickening $Z \subset Z'$ constructed in
Lemma \ref{lemma-universal-thickening}.
\item The {\it conormal sheaf of $Z$ over $X$} is the conormal sheaf
of $Z$ in its universal first order thickening $Z'$ over $X$.
\end{enumerate}
We often denote the conormal sheaf $\mathcal{C}_{Z/X}$ in this situation.
\end{definition}

\noindent
Thus we see that there is a short exact sequence of sheaves
$$
0 \to \mathcal{C}_{Z/X} \to \mathcal{O}_{Z'} \to \mathcal{O}_Z \to 0
$$
on $Z$.
The following lemma proves that there is no conflict between this definition
and the definition in case $Z \to X$ is an immersion.

\begin{lemma}
\label{lemma-immersion-universal-thickening}
Let $i : Z \to X$ be an immersion of schemes. Then
\begin{enumerate}
\item $i$ is formally unramified,
\item the universal first order thickening of $Z$ over $X$ is the first order
infinitesimal neighbourhood of $Z$ in $X$ of
Definition \ref{definition-first-order-infinitesimal-neighbourhood}, and
\item the conormal sheaf of $i$ in the sense of
Morphisms, Definition \ref{morphisms-definition-conormal-sheaf}
agrees with the conormal sheaf of $i$ in the sense of
Definition \ref{definition-universal-thickening}.
\end{enumerate}
\end{lemma}

\begin{proof}
By
Morphisms, Lemmas \ref{morphisms-lemma-open-immersion-unramified} and
\ref{morphisms-lemma-closed-immersion-unramified}
an immersion is unramified, hence formally unramified by
Lemma \ref{lemma-unramified-formally-unramified}.
The other assertions follow by combining
Lemmas \ref{lemma-first-order-infinitesimal-neighbourhood} and
\ref{lemma-infinitesimal-neighbourhood-conormal}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-universal-thickening-unramified}
Let $Z \to X$ be a formally unramified morphism of schemes.
Then the universal first order thickening $Z'$ is formally
unramified over $X$.
\end{lemma}

\begin{proof}
There are two proofs. The first is to show that $\Omega_{Z'/X} = 0$
by working affine locally and applying
Algebra, Lemma \ref{algebra-lemma-differentials-universal-thickening}.
Then
Lemma \ref{lemma-formally-unramified-differentials}
implies what we want.
The second is a direct argument as follows.

\medskip\noindent
Let $T \subset T'$ be a first order thickening. Let
$$
\xymatrix{
Z' \ar[d] & T \ar[l]^c \ar[d] \\
X & T' \ar[l] \ar[lu]^{a, b}
}
$$
be a commutative diagram. Consider two morphisms $a, b : T' \to Z'$
fitting into the diagram. Set $T_0 = c^{-1}(Z) \subset T$ and
$T'_a = a^{-1}(Z)$ (scheme theoretically).
Since $Z'$ is a first order thickening of $Z$, we see that $T'$
is a first order thickening of $T'_a$. Moreover, since $c = a|_T$ we see that
$T_0 = T \cap T'_a$ (scheme theoretically). As $T'$ is a first order
thickening of $T$ it follows that $T'_a$
is a first order thickening of $T_0$. Now $a|_{T'_a}$ and $b|_{T'_a}$
are morphisms of $T'_a$ into $Z'$ over $X$ which agree on $T_0$ as
morphisms into $Z$. Hence by the universal property of $Z'$ we conclude that
$a|_{T'_a} = b|_{T'_a}$. Thus $a$ and $b$ are morphism from
the first order thickening $T'$ of $T'_a$ whose restrictions to
$T'_a$ agree as morphisms into $Z$. Thus using the universal property of
$Z'$ once more we conclude that $a = b$. In other words, the defining
property of a formally unramified morphism holds for $Z' \to X$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-universal-thickening-functorial}
Consider a commutative diagram of schemes
$$
\xymatrix{
Z \ar[r]_h \ar[d]_f & X \ar[d]^g \\
W \ar[r]^{h'} & Y
}
$$
with $h$ and $h'$ formally unramified. Let $Z \subset Z'$ be the universal
first order thickening of $Z$ over $X$. Let $W \subset W'$ be the universal
first order thickening of $W$ over $Y$. There exists a canonical morphism
$(f, f') : (Z, Z') \to (W, W')$ of thickenings over $Y$ which fits into
the following commutative diagram
$$
\xymatrix{
& & & Z' \ar[ld] \ar[d]^{f'} \\
Z \ar[rr] \ar[d]_f \ar[rrru] & & X \ar[d] & W' \ar[ld] \\
W \ar[rrru]|!{[rr];[rruu]}\hole \ar[rr] & & Y
}
$$
In particular the morphism $(f, f')$ of thickenings induces a morphism
of conormal sheaves $f^*\mathcal{C}_{W/Y} \to \mathcal{C}_{Z/X}$.
\end{lemma}

\begin{proof}
The first assertion is clear from the universal property of $W'$.
The induced map on conormal sheaves is the map of
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial}
applied to $(Z \subset Z') \to (W \subset W')$.
\end{proof}

\begin{lemma}
\label{lemma-universal-thickening-fibre-product}
Let
$$
\xymatrix{
Z \ar[r]_h \ar[d]_f & X \ar[d]^g \\
W \ar[r]^{h'} & Y
}
$$
be a fibre product diagram in the category of schemes with
$h'$ formally unramified. Then $h$ is formally unramified and if
$W \subset W'$ is the universal first order thickening of $W$ over $Y$,
then $Z = X \times_Y W \subset X \times_Y W'$ is the universal
first order thickening of $Z$ over $X$. In particular the canonical map
$f^*\mathcal{C}_{W/Y} \to \mathcal{C}_{Z/X}$ of
Lemma \ref{lemma-universal-thickening-functorial}
is surjective.
\end{lemma}

\begin{proof}
The morphism $h$ is formally unramified by
Lemma \ref{lemma-base-change-formally-unramified}.
It is clear that $X \times_Y W'$ is a first order thickening.
It is straightforward to check that it has the universal property
because $W'$ has the universal property (by mapping properties of
fibre products). See
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial-flat}
for why this implies that the map of conormal sheaves is surjective.
\end{proof}

\begin{lemma}
\label{lemma-universal-thickening-fibre-product-flat}
Let
$$
\xymatrix{
Z \ar[r]_h \ar[d]_f & X \ar[d]^g \\
W \ar[r]^{h'} & Y
}
$$
be a fibre product diagram in the category of schemes with
$h'$ formally unramified and $g$ flat. In this case the corresponding
map $Z' \to W'$ of universal first order thickenings is flat, and
$f^*\mathcal{C}_{W/Y} \to \mathcal{C}_{Z/X}$ is an isomorphism.
\end{lemma}

\begin{proof}
Flatness is preserved under base change, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-flat}.
Hence the first statement follows from the description of
$W'$ in Lemma \ref{lemma-universal-thickening-fibre-product}.
It is clear that $X \times_Y W'$ is a first order thickening.
It is straightforward to check that it has the universal property
because $W'$ has the universal property (by mapping properties of
fibre products). See
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial-flat}
for why this implies that the map of conormal sheaves is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-universal-thickening-localize}
Taking the universal first order thickenings commutes with taking opens.
More precisely, let $h : Z \to X$ be a formally unramified morphism of schemes.
Let $V \subset Z$, $U \subset X$ be opens such that $h(V) \subset U$.
Let $Z'$ be the universal first order thickening of $Z$ over $X$.
Then $h|_V : V \to U$ is formally unramified and the universal first
order thickening of $V$ over $U$ is the open subscheme $V' \subset Z'$
such that $V = Z \cap V'$. In particular,
$\mathcal{C}_{Z/X}|_V = \mathcal{C}_{V/U}$.
\end{lemma}

\begin{proof}
The first statement is
Lemma \ref{lemma-formally-unramified-on-opens}.
The compatibility of universal thickenings can be deduced from the proof of
Lemma \ref{lemma-universal-thickening},
or from
Algebra, Lemma \ref{algebra-lemma-universal-thickening-localize}
or deduced from
Lemma \ref{lemma-universal-thickening-fibre-product-flat}.
\end{proof}

\begin{lemma}
\label{lemma-differentials-universally-unramified}
Let $h : Z \to X$ be a formally unramified morphism of schemes over $S$.
Let $Z \subset Z'$ be the universal first order thickening of $Z$
over $X$ with structure morphism $h' : Z' \to X$. The canonical map
$$
c_{h'} : (h')^*\Omega_{X/S} \longrightarrow \Omega_{Z'/S}
$$
induces an isomorphism
$h^*\Omega_{X/S} \to \Omega_{Z'/S} \otimes \mathcal{O}_Z$.
\end{lemma}

\begin{proof}
The map $c_{h'}$ is the map defined in
Morphisms, Lemma \ref{morphisms-lemma-functoriality-differentials}.
If $i : Z \to Z'$ is the given closed immersion, then
$i^*c_{h'}$ is a map
$h^*\Omega_{X/S} \to \Omega_{Z'/S} \otimes \mathcal{O}_Z$.
Checking that it is an isomorphism reduces to the affine case
by localization, see
Lemma \ref{lemma-universal-thickening-localize}
and
Morphisms, Lemma \ref{morphisms-lemma-differentials-restrict-open}.
In this case the result is
Algebra, Lemma \ref{algebra-lemma-differentials-universal-thickening}.
\end{proof}

\begin{lemma}
\label{lemma-universally-unramified-differentials-sequence}
Let $h : Z \to X$ be a formally unramified morphism of schemes over $S$.
There is a canonical exact sequence
$$
\mathcal{C}_{Z/X} \to h^*\Omega_{X/S} \to \Omega_{Z/S} \to 0.
$$
The first arrow is induced by $\text{d}_{Z'/S}$ where
$Z'$ is the universal first order neighbourhood of $Z$ over $X$.
\end{lemma}

\begin{proof}
We know that there is a canonical exact sequence
$$
\mathcal{C}_{Z/Z'} \to
\Omega_{Z'/S} \otimes \mathcal{O}_Z \to
\Omega_{Z/S} \to 0.
$$
see
Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion}.
Hence the result follows on applying
Lemma \ref{lemma-differentials-universally-unramified}.
\end{proof}

\begin{lemma}
\label{lemma-two-unramified-morphisms}
Let
$$
\xymatrix{
Z \ar[r]_i \ar[rd]_j & X \ar[d] \\
& Y
}
$$
be a commutative diagram of schemes where $i$ and $j$ are formally
unramified. Then there is a canonical exact sequence
$$
\mathcal{C}_{Z/Y} \to
\mathcal{C}_{Z/X} \to
i^*\Omega_{X/Y} \to 0
$$
where the first arrow comes from
Lemma \ref{lemma-universal-thickening-functorial}
and the second from
Lemma \ref{lemma-universally-unramified-differentials-sequence}.
\end{lemma}

\begin{proof}
Denote $Z \to Z'$ the universal first order thickening of $Z$ over $X$.
Denote $Z \to Z''$ the universal first order thickening of $Z$ over $Y$.
By
Lemma \ref{lemma-universally-unramified-differentials-sequence}
here is a canonical morphism $Z' \to Z''$ so that we have a commutative
diagram
$$
\xymatrix{
Z \ar[r]_{i'} \ar[rd]_{j'} & Z' \ar[r] \ar[d] & X \ar[d] \\
& Z'' \ar[r] & Y
}
$$
Apply
Morphisms, Lemma \ref{morphisms-lemma-two-immersions}
to the left triangle to get an exact sequence
$$
\mathcal{C}_{Z/Z''} \to
\mathcal{C}_{Z/Z'} \to
(i')^*\Omega_{Z'/Z''} \to 0
$$
As $Z''$ is formally unramified over $Y$ (see
Lemma \ref{lemma-universal-thickening-unramified})
we have
$\Omega_{Z'/Z''} = \Omega_{Z/Y}$ (by combining
Lemma \ref{lemma-formally-unramified-differentials}
and
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials}).
Then we have $(i')^*\Omega_{Z'/Y} = i^*\Omega_{X/Y}$ by
Lemma \ref{lemma-differentials-universally-unramified}.
\end{proof}

\begin{lemma}
\label{lemma-transitivity-conormal}
Let $Z \to Y \to X$ be formally unramified morphisms of schemes.
\begin{enumerate}
\item If $Z \subset Z'$ is the universal first order thickening of $Z$
over $X$ and $Y \subset Y'$ is the universal first order thickening of $Y$
over $X$, then there is a morphism $Z' \to Y'$ and $Y \times_{Y'} Z'$ is
the universal first order thickening of $Z$ over $Y$.
\item There is a canonical exact sequence
$$
i^*\mathcal{C}_{Y/X} \to
\mathcal{C}_{Z/X} \to
\mathcal{C}_{Z/Y} \to 0
$$
where the maps come from
Lemma \ref{lemma-universal-thickening-functorial}
and $i : Z \to Y$ is the first morphism.
\end{enumerate}
\end{lemma}

\begin{proof}
The map $h : Z' \to Y'$ in (1) comes from
Lemma \ref{lemma-universal-thickening-functorial}.
The assertion that $Y \times_{Y'} Z'$ is the universal first order
thickening of $Z$ over $Y$ is clear from the universal properties
of $Z'$ and $Y'$. By
Morphisms, Lemma \ref{morphisms-lemma-transitivity-conormal}
we have an exact sequence
$$
(i')^*\mathcal{C}_{Y \times_{Y'} Z'/Z'} \to
\mathcal{C}_{Z/Z'} \to
\mathcal{C}_{Z/Y \times_{Y'} Z'} \to 0
$$
where $i' : Z \to Y \times_{Y'} Z'$ is the given morphism. By
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial-flat}
there exists a surjection
$h^*\mathcal{C}_{Y/Y'} \to \mathcal{C}_{Y \times_{Y'} Z'/Z'}$.
Combined with the equalities
$\mathcal{C}_{Y/Y'} = \mathcal{C}_{Y/X}$,
$\mathcal{C}_{Z/Z'} = \mathcal{C}_{Z/X}$, and
$\mathcal{C}_{Z/Y \times_{Y'} Z'} = \mathcal{C}_{Z/Y}$
this proves the lemma.
\end{proof}











\section{Formally \'etale morphisms}
\label{section-formally-etale}

\noindent
Recall that a ring map $R \to A$ is called {\it formally \'etale}
(see Algebra, Definition \ref{algebra-definition-formally-etale})
if for every commutative solid diagram
$$
\xymatrix{
A \ar[r] \ar@{-->}[rd] & B/I \\
R \ar[r] \ar[u] & B \ar[u]
}
$$
where $I \subset B$ is an ideal of square zero, there exists
exactly one dotted arrow which makes the diagram commute. This motivates
the following analogue for morphisms of schemes.

\begin{definition}
\label{definition-formally-etale}
Let $f : X \to S$ be a morphism of schemes.
We say $f$ is {\it formally \'etale} if given any solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l] \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
where $T \subset T'$ is a first order thickening of affine schemes over $S$
there exists exactly one dotted arrow making the diagram commute.
\end{definition}

\noindent
It is clear that a formally \'etale morphism is formally unramified.
Hence if $f : X \to S$ is formally \'etale, then $\Omega_{X/S}$ is zero, see
Lemma \ref{lemma-formally-unramified-differentials}.

\begin{lemma}
\label{lemma-formally-etale-not-affine}
If $f : X \to S$ is a formally \'etale morphism, then given
any solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l] \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
where $T \subset T'$ is a first order thickening of schemes over $S$
there exists exactly one dotted arrow making the diagram commute.
In other words, in
Definition \ref{definition-formally-etale}
the condition that $T$ be affine may be dropped.
\end{lemma}

\begin{proof}
Let $T' = \bigcup T'_i$ be an affine open covering, and let
$T_i = T \cap T'_i$. Then we get morphisms $a'_i : T'_i \to X$ fitting
into the diagram. By uniqueness we see that $a'_i$ and $a'_j$ agree on
any affine open subscheme of $T'_i \cap T'_j$. Hence $a'_i$ and
$a'_j$ agree on $T'_i \cap T'_j$. Thus we see that the morphisms $a'_i$
glue to a global morphism $a' : T' \to X$. The uniqueness of
$a'$ we have seen in
Lemma \ref{lemma-formally-unramified-not-affine}.
\end{proof}

\begin{lemma}
\label{lemma-composition-formally-etale}
A composition of formally \'etale morphisms is formally \'etale.
\end{lemma}

\begin{proof}
This is formal.
\end{proof}

\begin{lemma}
\label{lemma-base-change-formally-etale}
A base change of a formally \'etale morphism is formally \'etale.
\end{lemma}

\begin{proof}
This is formal.
\end{proof}

\begin{lemma}
\label{lemma-formally-etale-on-opens}
Let $f : X \to S$ be a morphism of schemes.
Let $U \subset X$ and $V \subset S$ be open subschemes such that
$f(U) \subset V$. If $f$ is formally \'etale, so is $f|_U : U \to V$.
\end{lemma}

\begin{proof}
Consider a solid diagram
$$
\xymatrix{
U \ar[d]_{f|_U} & T \ar[d]^i \ar[l]^a \\
V & T' \ar[l] \ar@{-->}[lu]
}
$$
as in Definition \ref{definition-formally-etale}. If $f$ is formally
ramified, then there exists exactly one $S$-morphism $a' : T' \to X$
such that $a'|_T = a$. Since $|T'| = |T|$ we conclude that $a'(T') \subset U$
which gives our unique morphism from $T'$ into $U$.
\end{proof}

\begin{lemma}
\label{lemma-characterize-formally-etale}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item $f$ is formally \'etale,
\item $f$ is formally unramified and the universal first order thickening
of $X$ over $S$ is equal to $X$,
\item $f$ is formally unramified and $\mathcal{C}_{X/S} = 0$, and
\item $\Omega_{X/S} = 0$ and $\mathcal{C}_{X/S} = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
Actually, the last assertion only make sense because $\Omega_{X/S} = 0$
implies that $\mathcal{C}_{X/S}$ is defined via
Lemma \ref{lemma-formally-unramified-differentials}
and
Definition \ref{definition-universal-thickening}.
This also makes it clear that (3) and (4) are equivalent.

\medskip\noindent
Either of the assumptions (1), (2), and (3) imply that $f$ is formally
unramified. Hence we may assume $f$ is formally unramified. The equivalence
of (1), (2), and (3) follow from the universal property of the universal
first order thickening $X'$ of $X$ over $S$ and the fact that
$X = X' \Leftrightarrow \mathcal{C}_{X/S} = 0$ since
after all by definition $\mathcal{C}_{X/S} = \mathcal{C}_{X/X'}$
is the ideal sheaf of $X$ in $X'$.
\end{proof}

\begin{lemma}
\label{lemma-unramified-flat-formally-etale}
An unramified flat morphism is formally \'etale.
\end{lemma}

\begin{proof}
Say $X \to S$ is unramified and flat. Then $\Delta : X \to X \times_S X$
is an open immersion, see
Morphisms, Lemma \ref{morphisms-lemma-diagonal-unramified-morphism}.
We have to show that $\mathcal{C}_{X/S}$ is zero.
Consider the two projections $p, q : X \times_S X \to X$.
As $f$ is formally unramified (see
Lemma \ref{lemma-unramified-formally-unramified}),
$q$ is formally unramified (see
Lemma \ref{lemma-base-change-formally-unramified}).
As $f$ is flat, $p$ is flat, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-flat}.
Hence $p^*\mathcal{C}_{X/S} = \mathcal{C}_q$ by
Lemma \ref{lemma-universal-thickening-fibre-product-flat}
where $\mathcal{C}_q$ denotes the conormal sheaf of the formally
unramified morphism $q : X \times_S X \to X$.
But $\Delta(X) \subset X \times_S X$ is an open subscheme
which maps isomorphically to $X$ via $q$. Hence by
Lemma \ref{lemma-universal-thickening-localize}
we see that $\mathcal{C}_q|_{\Delta(X)} = \mathcal{C}_{X/X} = 0$.
In other words, the pullback of $\mathcal{C}_{X/S}$ to $X$ via
the identity morphism is zero, i.e., $\mathcal{C}_{X/S} = 0$.
\end{proof}

\begin{lemma}
\label{lemma-affine-formally-etale}
Let $f : X \to S$ be a morphism of schemes.
Assume $X$ and $S$ are affine.
Then $f$ is formally \'etale if and only if
$\mathcal{O}_S(S) \to \mathcal{O}_X(X)$ is a formally \'etale
ring map.
\end{lemma}

\begin{proof}
This is immediate from the definitions
(Definition \ref{definition-formally-etale} and
Algebra, Definition \ref{algebra-definition-formally-etale})
by the equivalence of categories of rings and affine schemes,
see
Schemes, Lemma \ref{schemes-lemma-category-affine-schemes}.
\end{proof}

\begin{lemma}
\label{lemma-etale-formally-etale}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item The morphism $f$ is \'etale, and
\item the morphism $f$ is locally of finite presentation and
formally \'etale.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $f$ is \'etale.
An \'etale morphism is locally of finite presentation, flat and unramified, see
Morphisms, Section \ref{morphisms-section-etale}.
Hence $f$ is locally of finite presentation and formally \'etale, see
Lemma \ref{lemma-unramified-flat-formally-etale}.

\medskip\noindent
Conversely, suppose that $f$ is locally of finite presentation and
formally \'etale. Being \'etale is local in the Zariski topology on
$X$ and $S$, see
Morphisms, Lemma \ref{morphisms-lemma-etale-characterize}.
By
Lemma \ref{lemma-formally-etale-on-opens}
we can cover $X$ by affine opens $U$ which map into affine opens
$V$ such that $U \to V$ is formally \'etale (and of finite presentation, see
Morphisms,
Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}).
By
Lemma \ref{lemma-affine-formally-etale}
we see that the ring maps $\mathcal{O}(V) \to \mathcal{O}(U)$ are
formally \'etale (and of finite presentation).
We win by
Algebra, Lemma \ref{algebra-lemma-formally-etale-etale}.
(We will give another proof of this implication when we discuss
formally smooth morphisms.)
\end{proof}













\section{Infinitesimal deformations of maps}
\label{section-action-by-derivations}

\noindent
In this section we explain how a derivation can be used to
infinitesimally move a map. Throughout this section we use that
a sheaf on a thickening $X'$ of $X$ can be seen as a sheaf on $X$.

\begin{lemma}
\label{lemma-difference-derivation}
Let $S$ be a scheme.
Let $X \subset X'$ and $Y \subset Y'$ be two first order thickenings
over $S$. Let $(a, a'), (b, b') : (X \subset X') \to (Y \subset Y')$
be two morphisms of thickenings over $S$. Assume that
\begin{enumerate}
\item $a = b$, and
\item the two maps $a^*\mathcal{C}_{Y/Y'} \to \mathcal{C}_{X/X'}$
(Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial})
are equal.
\end{enumerate}
Then the map $(a')^\sharp - (b')^\sharp$ factors as
$$
\mathcal{O}_{Y'} \to \mathcal{O}_Y \xrightarrow{D}
a_*\mathcal{C}_{X/X'} \to a_*\mathcal{O}_{X'}
$$
where $D$ is an $\mathcal{O}_S$-derivation.
\end{lemma}

\begin{proof}
Instead of working on $Y$ we work on $X$. The advantage is that the pullback
functor $a^{-1}$ is exact. Using (1) and (2) we obtain a commutative diagram
with exact rows
$$
\xymatrix{
0 \ar[r] &
\mathcal{C}_{X/X'} \ar[r] &
\mathcal{O}_{X'} \ar[r] &
\mathcal{O}_X \ar[r] & 0 \\
0 \ar[r] &
a^{-1}\mathcal{C}_{Y/Y'} \ar[r] \ar[u] &
a^{-1}\mathcal{O}_{Y'}
\ar[r] \ar@<1ex>[u]^{(a')^\sharp} \ar@<-1ex>[u]_{(b')^\sharp} &
a^{-1}\mathcal{O}_Y \ar[r] \ar[u] & 0
}
$$
Now it is a general fact that in such a situation the difference of the
$\mathcal{O}_S$-algebra maps $(a')^\sharp$ and $(b')^\sharp$ is an
$\mathcal{O}_S$-derivation from $a^{-1}\mathcal{O}_Y$ to $\mathcal{C}_{X/X'}$.
By adjointness of the functors $a^{-1}$ and $a_*$ this is the same
thing as an $\mathcal{O}_S$-derivation from
$\mathcal{O}_Y$ into $a_*\mathcal{C}_{X/X'}$. Some details omitted.
\end{proof}

\noindent
Note that in the situation of the lemma above we may write
$D$ as
\begin{equation}
\label{equation-D}
D = \text{d}_{Y/S} \circ \theta
\end{equation}
where $\theta$ is an $\mathcal{O}_Y$-linear map
$\theta : \Omega_{Y/S} \to a_*\mathcal{C}_{X/X'}$.
Of course, then by adjunction again we may view $\theta$ as an
$\mathcal{O}_X$-linear map
$\theta : a^*\Omega_{Y/S} \to \mathcal{C}_{X/X'}$.

\begin{lemma}
\label{lemma-action-by-derivations}
Let $S$ be a scheme.
Let $(a, a') : (X \subset X') \to (Y \subset Y')$
be a morphism of first order thickenings over $S$.
Let
$$
\theta : a^*\Omega_{Y/S} \to \mathcal{C}_{X/X'}
$$
be an $\mathcal{O}_X$-linear map. Then there exists a unique morphism of pairs
$(b, b') : (X \subset X') \to (Y \subset Y')$ such that
(1) and (2) of
Lemma \ref{lemma-difference-derivation}
hold and the derivation $D$ and $\theta$ are related by
Equation (\ref{equation-D}).
\end{lemma}

\begin{proof}
We simply set $b = a$ and we define $(b')^\sharp$ to be the map
$$
(a')^\sharp + D : a^{-1}\mathcal{O}_{Y'} \to \mathcal{O}_{X'}
$$
where $D$ is as in Equation (\ref{equation-D}). We omit the verification
that $(b')^\sharp$ is a map of sheaves of $\mathcal{O}_S$-algebras and
that (1) and (2) of
Lemma \ref{lemma-difference-derivation}
hold. Equation (\ref{equation-D}) holds by construction.
\end{proof}

\begin{remark}
\label{remark-action-by-derivations}
Assumptions and notation as in Lemma \ref{lemma-action-by-derivations}.
The action of a local section $\theta$ on $a'$ is sometimes indicated by
$\theta \cdot a'$. Note that this means nothing else than the fact
that $(a')^\sharp$ and $(\theta \cdot a')^\sharp$ differ by a derivation
$D$ which is related to $\theta$ by Equation (\ref{equation-D}).
\end{remark}

\begin{lemma}
\label{lemma-sheaf}
Let $S$ be a scheme.
Let $X \subset X'$ and $Y \subset Y'$ be first order thickenings
over $S$. Assume given a morphism $a : X \to Y$ and a map
$A : a^*\mathcal{C}_{Y/Y'} \to \mathcal{C}_{X/X'}$ of
$\mathcal{O}_X$-modules. For an open subscheme $U' \subset X'$
consider morphisms $a' : U' \to Y'$ such that
\begin{enumerate}
\item $a'$ is a morphism over $S$,
\item $a'|_U = a|_U$, and
\item the induced map
$a^*\mathcal{C}_{Y/Y'}|_U \to \mathcal{C}_{X/X'}|_U$
is the restriction of $A$ to $U$.
\end{enumerate}
Here $U = X \cap U'$. Then the rule
\begin{equation}
\label{equation-sheaf}
U' \mapsto
\{a' : U' \to Y'\text{ such that (1), (2), (3) hold.}\}
\end{equation}
defines a sheaf of sets on $X'$.
\end{lemma}

\begin{proof}
Denote $\mathcal{F}$ the rule of the lemma.
The restriction mapping $\mathcal{F}(U') \to \mathcal{F}(V')$ for
$V' \subset U' \subset X'$
of $\mathcal{F}$ is really the restriction map $a' \mapsto a'|_{V'}$.
With this definition in place it is clear that $\mathcal{F}$ is a
sheaf since morphisms are defined locally.
\end{proof}

\noindent
In the following lemma we identify sheaves on $X$ and any thickening
of $X$.

\begin{lemma}
\label{lemma-action-sheaf}
Same notation and assumptions as in Lemma \ref{lemma-sheaf}.
There is an action of the sheaf
$$
\SheafHom_{\mathcal{O}_X}(a^*\Omega_{Y/S}, \mathcal{C}_{X/X'})
$$
on the sheaf (\ref{equation-sheaf}). Moreover, the action
is simply transitive for any open $U' \subset X'$ over which the sheaf
(\ref{equation-sheaf}) has a section.
\end{lemma}

\begin{proof}
This is a combination of
Lemmas \ref{lemma-difference-derivation},
\ref{lemma-action-by-derivations},
and \ref{lemma-sheaf}.
\end{proof}

\begin{remark}
\label{remark-special-case}
A special case of
Lemmas \ref{lemma-difference-derivation},
\ref{lemma-action-by-derivations},
\ref{lemma-sheaf}, and
\ref{lemma-action-sheaf}
is where $Y = Y'$. In this case the map $A$ is always zero.
The sheaf of
Lemma \ref{lemma-sheaf}
is just given by the rule
$$
U' \mapsto
\{a' : U' \to Y\text{ over }S\text{ with } a'|_U = a|_U\}
$$
and we act on this by the sheaf
$\SheafHom_{\mathcal{O}_X}(a^*\Omega_{Y/S}, \mathcal{C}_{X/X'})$.
\end{remark}

\begin{remark}
\label{remark-another-special-case}
Another special case of
Lemmas \ref{lemma-difference-derivation},
\ref{lemma-action-by-derivations},
\ref{lemma-sheaf}, and
\ref{lemma-action-sheaf}
is where $S$ itself is a thickening $Z \subset Z' = S$
and $Y = Z \times_{Z'} Y'$. Picture
$$
\xymatrix{
(X \subset X') \ar@{..>}[rr]_{(a, ?)} \ar[rd]_{(g, g')} & &
(Y \subset Y') \ar[ld]^{(h, h')} \\
& (Z \subset Z')
}
$$
In this case the map $A : a^*\mathcal{C}_{Y/Y'} \to \mathcal{C}_{X/X'}$
is determined by $a$: the map
$h^*\mathcal{C}_{Z/Z'} \to \mathcal{C}_{Y/Y'}$ is surjective (because
we assumed $Y = Z \times_{Z'} Y'$),
hence the pullback $g^*\mathcal{C}_{Z/Z'} = a^*h^*\mathcal{C}_{Z/Z'} \to
a^*\mathcal{C}_{Y/Y'}$ is surjective, and the composition
$g^*\mathcal{C}_{Z/Z'} \to a^*\mathcal{C}_{Y/Y'} \to \mathcal{C}_{X/X'}$
has to be the canonical map induced by $g'$. Thus the sheaf of
Lemma \ref{lemma-sheaf}
is just given by the rule
$$
U' \mapsto
\{a' : U' \to Y'\text{ over }Z'\text{ with } a'|_U = a|_U\}
$$
and we act on this by the sheaf
$\SheafHom_{\mathcal{O}_X}(a^*\Omega_{Y/Z}, \mathcal{C}_{X/X'})$.
\end{remark}

\begin{lemma}
\label{lemma-omega-deformation}
Let $S$ be a scheme. Let $X \subset X'$ be a first order thickening over
$S$. Let $Y$ be a scheme over $S$. Let
$a', b' : X' \to Y$ be two morphisms over $S$ with
$a = a'|_X = b'|_X$. This gives rise to a commutative diagram
$$
\xymatrix{
X \ar[r] \ar[d]_a & X' \ar[d]^{(b', a')} \\
Y \ar[r]^-{\Delta_{Y/S}} & Y \times_S Y
}
$$
Since the horizontal arrows are immersions with conormal sheaves
$\mathcal{C}_{X/X'}$ and $\Omega_{Y/S}$, by
Morphisms, Lemma \ref{morphisms-lemma-conormal-functorial},
we obtain a map $\theta : a^*\Omega_{Y/S} \to \mathcal{C}_{X/X'}$.
Then this $\theta$ and the derivation $D$ of
Lemma \ref{lemma-difference-derivation}
are related by Equation (\ref{equation-D}).
\end{lemma}

\begin{proof}
Omitted. Hint: The equality may be checked on affine opens where it
comes from the following computation. If $f$ is a local section of
$\mathcal{O}_Y$, then $1 \otimes f - f \otimes 1$ is a local section
of $\mathcal{C}_{Y/(Y \times_S Y)}$ corresponding to $\text{d}_{Y/S}(f)$.
It is mapped to the local section $(a')^\sharp(f) - (b')^\sharp(f) = D(f)$
of $\mathcal{C}_{X/X'}$. In other words, $\theta(\text{d}_{Y/S}(f)) = D(f)$.
\end{proof}

\noindent
For later purposes we need a result that roughly states that the
construction of
Lemma \ref{lemma-action-by-derivations}
is compatible with \'etale localization.

\begin{lemma}
\label{lemma-sheaf-differentials-etale-localization}
Let
$$
\xymatrix{
X_1 \ar[d] & X_2 \ar[l]^f \ar[d] \\
S_1 & S_2 \ar[l]
}
$$
be a commutative diagram of schemes with $X_2 \to X_1$ and $S_2 \to S_1$
\'etale. Then the map $c_f : f^*\Omega_{X_1/S_1} \to \Omega_{X_2/S_2}$ of
Morphisms, Lemma \ref{morphisms-lemma-functoriality-differentials}
is an isomorphism.
\end{lemma}

\begin{proof}
We recall that an \'etale morphism $U \to V$ is a smooth morphism
with $\Omega_{U/V} = 0$. Using this we see that
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials}
implies $\Omega_{X_2/S_2} = \Omega_{X_2/S_1}$ and
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials-smooth}
implies that the map $f^*\Omega_{X_1/S_1} \to \Omega_{X_2/S_1}$
(for the morphism $f$ seen as a morphism over $S_1$)
is an isomorphism. Hence the lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-action-by-derivations-etale-localization}
Consider a commutative diagram of first order thickenings
$$
\vcenter{
\xymatrix{
(T_2 \subset T_2') \ar[d]_{(h, h')} \ar[rr]_{(a_2, a_2')} & &
(X_2 \subset X_2') \ar[d]^{(f, f')} \\
(T_1 \subset T_1') \ar[rr]^{(a_1, a_1')} & &
(X_1 \subset X_1')
}
}
\quad
\begin{matrix}
\text{and a commutative} \\
\text{diagram of schemes}
\end{matrix}
\quad
\vcenter{
\xymatrix{
X_2' \ar[r] \ar[d] & S_2 \ar[d] \\
X_1' \ar[r] & S_1
}
}
$$
with $X_2 \to X_1$ and $S_2 \to S_1$ \'etale.
For any $\mathcal{O}_{T_1}$-linear map
$\theta_1 : a_1^*\Omega_{X_1/S_1} \to \mathcal{C}_{T_1/T'_1}$ let
$\theta_2$ be the composition
$$
\xymatrix{
a_2^*\Omega_{X_2/S_2} \ar@{=}[r] &
h^*a_1^*\Omega_{X_1/S_1} \ar[r]^-{h^*\theta_1} &
h^*\mathcal{C}_{T_1/T'_1} \ar[r] &
\mathcal{C}_{T_2/T'_2}
}
$$
(equality sign is explained in the proof). Then the diagram
$$
\xymatrix{
T_2' \ar[rr]_{\theta_2 \cdot a_2'} \ar[d] & & X'_2 \ar[d] \\
T_1' \ar[rr]^{\theta_1 \cdot a_1'} & & X'_1
}
$$
commutes where the actions $\theta_2 \cdot a_2'$ and $\theta_1 \cdot a_1'$
are as in Remark \ref{remark-action-by-derivations}.
\end{lemma}

\begin{proof}
The equality sign comes from the identification
$f^*\Omega_{X_1/S_1} = \Omega_{X_2/S_2}$ of
Lemma \ref{lemma-sheaf-differentials-etale-localization}.
Namely, using this we have
$a_2^*\Omega_{X_2/S_2} = a_2^*f^*\Omega_{X_1/S_1} =
h^*a_1^*\Omega_{X_1/S_1}$ because $f \circ a_2 = a_1 \circ h$.
Having said this, the commutativity of the diagram may be checked
on affine opens. Hence we may assume the schemes in the initial
big diagram are affine. Thus we obtain commutative diagrams
$$
\vcenter{
\xymatrix{
(B'_2, I_2) & & (A'_2, J_2) \ar[ll]^{a_2'} \\
(B'_1, I_1) \ar[u]^{h'} & & (A'_1, J_1) \ar[ll]_{a_1'} \ar[u]_{f'}
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
A'_2 & & R_2 \ar[ll] \\
A'_1 \ar[u] & & R_1 \ar[ll] \ar[u]
}
}
$$
The notation signifies that $I_1, I_2, J_1, J_2$ are ideals of square
zero and maps of pairs are ring maps sending ideals into ideals.
Set $A_1 = A'_1/J_1$, $A_2 = A'_2/J_2$, $B_1 = B'_1/I_1$, and
$B_2 = B'_2/I_2$. We are given that
$$
A_2 \otimes_{A_1} \Omega_{A_1/R_1} \longrightarrow \Omega_{A_2/R_2}
$$
is an isomorphism. Then
$\theta_1 : B_1 \otimes_{A_1} \Omega_{A_1/R_1} \to I_1$
is $B_1$-linear. This gives an $R_1$-derivation
$D_1 = \theta_1 \circ \text{d}_{A_1/R_1} : A_1 \to I_1$.
In a similar way we see that
$\theta_2 : B_2 \otimes_{A_2} \Omega_{A_2/R_2} \to I_2$
gives rise to a $R_2$-derivation
$D_2 = \theta_2 \circ \text{d}_{A_2/R_2} : A_2 \to I_2$.
The construction of $\theta_2$ implies the following compatibility between
$\theta_1$ and $\theta_2$: for every $x \in A_1$ we have
$$
h'(D_1(x)) = D_2(f'(x))
$$
as elements of $I_2$. We may view $D_1$ as a map $A'_1 \to B'_1$
using $A'_1 \to A_1 \xrightarrow{D_1} I_1 \to B_1$ similarly
we may view $D_2$ as a map $A'_2 \to B'_2$. Then the displayed
equality holds for $x \in A'_1$.
By the construction of the action in
Lemma \ref{lemma-action-by-derivations} and
Remark \ref{remark-action-by-derivations}
we know that $\theta_1 \cdot a_1'$ corresponds to the ring map
$a_1' + D_1 : A'_1 \to B'_1$ and $\theta_2 \cdot a_2'$ corresponds
to the ring map $a_2' + D_2 : A'_2 \to B'_2$. By the displayed equality
we obtain that
$h' \circ (a_1' + D_1) = (a_2' + D_2) \circ f'$
as desired.
\end{proof}

\begin{remark}
\label{remark-tiny-improvement}
Lemma \ref{lemma-action-by-derivations-etale-localization}
can be improved in the following way.
Suppose that we have commutative diagrams as in
Lemma \ref{lemma-action-by-derivations-etale-localization}
but we do not assume that $X_2 \to X_1$
and $S_2 \to S_1$ are \'etale. Next, suppose we have
$\theta_1 : a_1^*\Omega_{X_1/S_1} \to \mathcal{C}_{T_1/T'_1}$
and
$\theta_2 : a_2^*\Omega_{X_2/S_2} \to \mathcal{C}_{T_2/T'_2}$
such that
$$
\xymatrix{
f_*\mathcal{O}_{X_2} \ar[rr]_{f_*D_2} & &
f_*a_{2, *}\mathcal{C}_{T_2/T_2'} \\
\mathcal{O}_{X_1} \ar[rr]^{D_1} \ar[u]^{f^\sharp} & &
a_{1, *}\mathcal{C}_{T_1/T_1'} \ar[u]_{\text{induced by }(h')^\sharp}
}
$$
is commutative where $D_i$ corresponds to $\theta_i$ as in
Equation (\ref{equation-D}). Then we have the conclusion of
Lemma \ref{lemma-action-by-derivations-etale-localization}.
The importance of the condition that both $X_2 \to X_1$ and
$S_2 \to S_1$ are \'etale is that it allows us to construct a $\theta_2$
from $\theta_1$.
\end{remark}








\section{Infinitesimal deformations of schemes}
\label{section-deform}

\noindent
The following simple lemma is often a convenient tool to check whether
an infinitesimal deformation of a map is flat.

\begin{lemma}
\label{lemma-deform}
Let $(f, f') : (X \subset X') \to (S \subset S')$ be a morphism
of first order thickenings. Assume that $f$ is flat.
Then the following are equivalent
\begin{enumerate}
\item $f'$ is flat and $X = S \times_{S'} X'$, and
\item the canonical map $f^*\mathcal{C}_{S/S'} \to \mathcal{C}_{X/X'}$
is an isomorphism.
\end{enumerate}
\end{lemma}

\begin{proof}
As the problem is local on $X'$ we may assume that $X, X', S, S'$
are affine schemes. Say $S' = \Spec(A')$, $X' = \Spec(B')$,
$S = \Spec(A)$, $X = \Spec(B)$ with $A = A'/I$ and $B = B'/J$
for some square zero ideals. Then we obtain the following commutative
diagram
$$
\xymatrix{
0 \ar[r] &
J \ar[r] &
B' \ar[r] &
B \ar[r] & 0 \\
0 \ar[r] &
I \ar[r] \ar[u] &
A' \ar[r] \ar[u] &
A \ar[r] \ar[u] & 0
}
$$
with exact rows. The canonical map of the lemma is the map
$$
I \otimes_A B = I \otimes_{A'} B' \longrightarrow J.
$$
The assumption that $f$ is flat signifies that $A \to B$ is flat.

\medskip\noindent
Assume (1). Then $A' \to B'$ is flat and $J = IB'$. Flatness implies
$\text{Tor}_1^{A'}(B', A) = 0$ (see
Algebra, Lemma \ref{algebra-lemma-characterize-flat}).
This means $I \otimes_{A'} B' \to B'$ is injective (see
Algebra, Remark \ref{algebra-remark-Tor-ring-mod-ideal}).
Hence we see that $I \otimes_A B \to J$ is an isomorphism.

\medskip\noindent
Assume (2). Then it follows that $J = IB'$, so that $X = S \times_{S'} X'$.
Moreover, we get $\text{Tor}_1^{A'}(B', A'/I) = 0$ by reversing the
implications in the previous paragraph. Hence $B'$ is flat over $A'$ by
Algebra, Lemma \ref{algebra-lemma-what-does-it-mean}.
\end{proof}

\noindent
The following lemma is the ``nilpotent'' version of the
``crit\`ere de platitude par fibres'', see
Section \ref{section-criterion-flat-fibres}.

\begin{lemma}
\label{lemma-flatness-morphism-thickenings}
Consider a commutative diagram
$$
\xymatrix{
(X \subset X') \ar[rr]_{(f, f')} \ar[rd] & & (Y \subset Y') \ar[ld] \\
& (S \subset S')
}
$$
of thickenings. Assume
\begin{enumerate}
\item $X'$ is flat over $S'$,
\item $f$ is flat,
\item $S \subset S'$ is a finite order thickening, and
\item $X = S \times_{S'} X'$ and $Y = S \times_{S'} Y'$.
\end{enumerate}
Then $f'$ is flat and $Y'$ is flat over $S'$ at all points in
the image of $f'$.
\end{lemma}

\begin{proof}
Immediate consequence of
Algebra, Lemma \ref{algebra-lemma-criterion-flatness-fibre-nilpotent}.
\end{proof}

\noindent
Many properties of morphisms of schemes are preserved under flat
deformations.

\begin{lemma}
\label{lemma-deform-property}
Consider a commutative diagram
$$
\xymatrix{
(X \subset X') \ar[rr]_{(f, f')} \ar[rd] & & (Y \subset Y') \ar[ld] \\
& (S \subset S')
}
$$
of thickenings. Assume $S \subset S'$ is a finite order thickening,
$X'$ flat over $S'$, $X = S \times_{S'} X'$, and
$Y = S \times_{S'} Y'$. Then
\begin{enumerate}
\item $f$ is flat if and only if $f'$ is flat,
\label{item-flat}
\item $f$ is an isomorphism if and only if $f'$ is an isomorphism,
\label{item-isomorphism}
\item $f$ is an open immersion if and only if $f'$ is an open immersion,
\label{item-open-immersion}
\item $f$ is quasi-compact if and only if $f'$ is quasi-compact,
\label{item-quasi-compact}
\item $f$ is universally closed if and only if $f'$ is universally closed,
\label{item-universally-closed}
\item $f$ is (quasi-)separated if and only if $f'$ is (quasi-)separated,
\label{item-separated}
\item $f$ is a monomorphism if and only if $f'$ is a monomorphism,
\label{item-monomorphism}
\item $f$ is surjective if and only if $f'$ is surjective,
\label{item-surjective}
\item $f$ is universally injective if and only if $f'$ is universally injective,
\label{item-universally-injective}
\item $f$ is affine if and only if $f'$ is affine,
\label{item-affine}
\item
\label{item-finite-type}
$f$ is locally of finite type if and only if $f'$ is locally of finite type,
\item $f$ is locally quasi-finite if and only if $f'$ is locally quasi-finite,
\label{item-quasi-finite}
\item
\label{item-finite-presentation}
$f$ is locally of finite presentation if and only if $f'$ is locally of
finite presentation,
\item
\label{item-relative-dimension-d}
$f$ is locally of finite type of relative dimension $d$ if and only if
$f'$ is locally of finite type of relative dimension $d$,
\item $f$ is universally open if and only if $f'$ is universally open,
\label{item-universally-open}
\item $f$ is syntomic if and only if $f'$ is syntomic,
\label{item-syntomic}
\item $f$ is smooth if and only if $f'$ is smooth,
\label{item-smooth}
\item $f$ is unramified if and only if $f'$ is unramified,
\label{item-unramified}
\item $f$ is \'etale if and only if $f'$ is \'etale,
\label{item-etale}
\item $f$ is proper if and only if $f'$ is proper,
\label{item-proper}
\item $f$ is integral if and only if $f'$ is integral,
\label{item-integral}
\item $f$ is finite if and only if $f'$ is finite,
\label{item-finite}
\item
\label{item-finite-locally-free}
$f$ is finite locally free (of rank $d$) if and only if $f'$
is finite locally free (of rank $d$), and
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
The assumptions on $X$ and $Y$ mean that $f$ is the base change of
$f'$ by $X \to X'$.
The properties $\mathcal{P}$ listed in (1) -- (23) above are all stable
under base change, hence if $f'$ has property $\mathcal{P}$, then so
does $f$. See
Schemes, Lemmas \ref{schemes-lemma-base-change-immersion},
\ref{schemes-lemma-quasi-compact-preserved-base-change},
\ref{schemes-lemma-separated-permanence}, and
\ref{schemes-lemma-base-change-monomorphism}
and
Morphisms, Lemmas
\ref{morphisms-lemma-base-change-surjective},
\ref{morphisms-lemma-base-change-universally-injective},
\ref{morphisms-lemma-base-change-affine},
\ref{morphisms-lemma-base-change-finite-type},
\ref{morphisms-lemma-base-change-quasi-finite},
\ref{morphisms-lemma-base-change-finite-presentation},
\ref{morphisms-lemma-base-change-relative-dimension-d},
\ref{morphisms-lemma-base-change-syntomic},
\ref{morphisms-lemma-base-change-smooth},
\ref{morphisms-lemma-base-change-unramified},
\ref{morphisms-lemma-base-change-etale},
\ref{morphisms-lemma-base-change-proper},
\ref{morphisms-lemma-base-change-finite}, and
\ref{morphisms-lemma-base-change-finite-locally-free}.

\medskip\noindent
The interesting direction in each case is therefore to assume
that $f$ has the property and deduce that $f'$ has it too.
By induction on the order of the thickening we may
assume that $S \subset S'$ is a first order thickening, see
discussion immediately following
Definition \ref{definition-thickening}.
We make a couple of general remarks which we will use without further
mention in the arguments below.
(I) Let $W' \subset S'$ be an affine open and let $U' \subset X'$
and $V' \subset Y'$ be affine opens lying over $W'$ with $f'(U') \subset V'$.
Let $W' = \Spec(R')$ and denote $I \subset R'$ be the ideal
defining the closed subscheme $W' \cap S$. Say $U' = \Spec(B')$
and $V' = \Spec(A')$. Then we get a commutative diagram
$$
\xymatrix{
0 \ar[r] &
IB' \ar[r] &
B' \ar[r] &
B \ar[r] & 0 \\
0 \ar[r] &
IA' \ar[r] \ar[u] &
A' \ar[r] \ar[u] &
A \ar[r] \ar[u] & 0
}
$$
with exact rows. Moreover $IB' \cong I \otimes_R B$, see proof of
Lemma \ref{lemma-deform}.
(II) The morphisms $X \to X'$ and $Y \to Y'$ are universal homeomorphisms.
Hence the topology of the maps $f$ and $f'$ (after any base change)
is identical. (III) If $f$ is flat, then $f'$ is flat and
$Y' \to S'$ is flat at every point in the image of $f'$, see
Lemma \ref{lemma-flatness-morphism-thickenings}.

\medskip\noindent
Ad (\ref{item-flat}). This is general remark (III).

\medskip\noindent
Ad (\ref{item-isomorphism}). Assume $f$ is an isomorphism.
By (III) we see that $Y' \to S'$ is flat. Choose an
affine open $V' \subset Y'$ and set $U' = (f')^{-1}(V')$. Then
$V = Y \cap V'$ is affine which implies that
$V \cong f^{-1}(V) = U = Y \times_{Y'} U'$ is affine. By
Lemma \ref{lemma-thickening-affine-scheme}
we see that $U'$ is affine. Thus we have a diagram as in the
general remark (I) and moreover $IA \cong I \otimes_R A$ because
$R' \to A'$ is flat. Then
$IB' \cong I \otimes_R B \cong I \otimes_R A \cong IA'$
and $A \cong B$. By the exactness of the rows
in the diagram above we see that $A' \cong B'$,
i.e., $U' \cong V'$. Thus $f'$ is an isomorphism.

\medskip\noindent
Ad (\ref{item-open-immersion}). Assume $f$ is an open immersion.
Then $f$ is an isomorphism of $X$ with an open subscheme $V \subset Y$.
Let $V' \subset Y'$ be the open subscheme whose underlying topological
space is $V$. Then $f'$ is a map from $X'$ to $V'$ which is an isomorphism by
(\ref{item-isomorphism}). Hence $f'$ is an open immersion.

\medskip\noindent
Ad (\ref{item-quasi-compact}). Immediate from remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-universally-closed}). Immediate from remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-separated}). Note that
$X \times_Y X = Y \times_{Y'} (X' \times_{Y'} X')$ so that
$X' \times_{Y'} X'$ is a thickening of $X \times_Y X$.
Hence the topology of the maps $\Delta_{X/Y}$ and $\Delta_{X'/Y'}$
matches and we win. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-monomorphism}). Assume $f$ is a monomorphism.
Consider the diagonal morphism $\Delta_{X'/Y'} : X' \to X' \times_{Y'} X'$.
The base change of $\Delta_{X'/Y'}$ by $S \to S'$ is $\Delta_{X/Y}$
which is an isomorphism by assumption. By (\ref{item-isomorphism})
we conclude that $\Delta_{X'/Y'}$ is an isomorphism.

\medskip\noindent
Ad (\ref{item-surjective}). This is clear. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-universally-injective}). Immediate from remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-affine}). Assume $f$ is affine.  Choose an
affine open $V' \subset Y'$ and set $U' = (f')^{-1}(V')$.
Then $V = Y \cap V'$ is affine which implies that
$U = Y \times_{Y'} U'$ is affine. By
Lemma \ref{lemma-thickening-affine-scheme}
we see that $U'$ is affine. Hence $f'$ is affine. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-finite-type}). Via remark (I) comes down to proving $A' \to B'$
is of finite type if $A \to B$ is of finite type. Suppose that
$x_1, \ldots, x_n \in B'$ are elements whose images in $B$ generate $B$
as an $A$-algebra. Then $A'[x_1, \ldots, x_n] \to B$ is surjective
as both $A'[x_1, \ldots, x_n] \to B$ is surjective and
$I \otimes_R A[x_1, \ldots, x_n] \to I \otimes_R B$ is surjective. See also
Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-quasi-finite}). Follows from (\ref{item-finite-type}) and that
quasi-finiteness of a morphism of finite type can be checked on fibres, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize}.
See also Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-finite-presentation}). Via remark (I) comes down to proving
$A' \to B'$ is of finite presentation if $A \to B$ is of finite presentation.
We may assume that $B' = A'[x_1, \ldots, x_n]/K'$ for some ideal $K'$ by
(\ref{item-finite-type}). We get a short exact sequence
$$
0 \to K' \to A'[x_1, \ldots, x_n] \to B' \to 0
$$
As $B'$ is flat over $R'$ we see that $K' \otimes_{R'} R$ is the kernel of
the surjection $A[x_1, \ldots, x_n] \to B$. By assumption on $A \to B$ there
exist finitely many $f'_1, \ldots, f'_m \in K'$ whose images in
$A[x_1, \ldots, x_n]$ generate this kernel. Since $I$ is nilpotent we see
that $f'_1, \ldots, f'_m$ generate $K'$ by Nakayama's lemma, see
Algebra, Lemma \ref{algebra-lemma-NAK}.

\medskip\noindent
Ad (\ref{item-relative-dimension-d}). Follows from (\ref{item-finite-type})
and general remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-universally-open}). Immediate from general remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-syntomic}). Assume $f$ is syntomic. By
(\ref{item-finite-presentation}) $f'$ is locally of finite presentation,
by general remark (III) $f'$ is flat and the fibres of $f'$ are the fibres
of $f$. Hence $f'$ is syntomic by
Morphisms, Lemma \ref{morphisms-lemma-syntomic-flat-fibres}.

\medskip\noindent
Ad (\ref{item-smooth}). Assume $f$ is smooth. By
(\ref{item-finite-presentation}) $f'$ is locally of finite presentation,
by general remark (III) $f'$ is flat, and the fibres of $f'$ are the
fibres of $f$. Hence $f'$ is smooth by
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat-smooth-fibres}.

\medskip\noindent
Ad (\ref{item-unramified}). Assume $f$ unramified. By
(\ref{item-finite-type}) $f'$ is locally of finite type
and the fibres of $f'$ are the fibres of $f$.
Hence $f'$ is unramified by
Morphisms, Lemma \ref{morphisms-lemma-unramified-etale-fibres}. See also
Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-etale}). Assume $f$ \'etale. By
(\ref{item-finite-presentation}) $f'$ is locally of finite presentation,
by general remark (III) $f'$ is flat, and the fibres of $f'$ are the fibres
of $f$. Hence $f'$ is \'etale by
Morphisms, Lemma \ref{morphisms-lemma-etale-flat-etale-fibres}.

\medskip\noindent
Ad (\ref{item-proper}). This follows from a combination of
(\ref{item-separated}), (\ref{item-finite-type}), (\ref{item-quasi-compact}),
and (\ref{item-universally-closed}).  See also
Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-integral}). Combine (\ref{item-universally-closed}) and
(\ref{item-affine}) with
Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed}. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-finite}). Combine (\ref{item-integral}),
and (\ref{item-finite-type}) with
Morphisms, Lemma \ref{morphisms-lemma-finite-integral}. See also
Lemma \ref{lemma-thicken-property-morphisms-cartesian}
for a more general statement.

\medskip\noindent
Ad (\ref{item-finite-locally-free}). Assume $f$ finite locally free. By
(\ref{item-finite}) we see that $f'$ is finite, by general remark (III)
$f'$ is flat, and by (\ref{item-finite-presentation}) $f'$ is locally of finite
presentation. Hence $f'$ is finite locally free by
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}.
\end{proof}

\noindent
The following lemma is the ``locally nilpotent'' version of the
``crit\`ere de platitude par fibres'', see
Section \ref{section-criterion-flat-fibres}.

\begin{lemma}
\label{lemma-flatness-morphism-thickenings-fp-over-ft}
Consider a commutative diagram
$$
\xymatrix{
(X \subset X') \ar[rr]_{(f, f')} \ar[rd] & & (Y \subset Y') \ar[ld] \\
& (S \subset S')
}
$$
of thickenings. Assume
\begin{enumerate}
\item $Y' \to S'$ is locally of finite type,
\item $X' \to S'$ is flat and locally of finite presentation,
\item $f$ is flat, and
\item $X = S \times_{S'} X'$ and $Y = S \times_{S'} Y'$.
\end{enumerate}
Then $f'$ is flat and for all $y' \in Y'$ in the image of $f'$
the local ring $\mathcal{O}_{Y', y'}$ is
flat and essentially of finite presentation over $\mathcal{O}_{S', s'}$.
\end{lemma}

\begin{proof}
Immediate consequence of
Algebra, Lemma \ref{algebra-lemma-criterion-flatness-fibre-locally-nilpotent}.
\end{proof}

\noindent
Many properties of morphisms of schemes are preserved under flat
deformations as in the lemma above.

\begin{lemma}
\label{lemma-deform-property-fp-over-ft}
Consider a commutative diagram
$$
\xymatrix{
(X \subset X') \ar[rr]_{(f, f')} \ar[rd] & & (Y \subset Y') \ar[ld] \\
& (S \subset S')
}
$$
of thickenings. Assume $Y' \to S'$ locally of finite type,
$X' \to S'$ flat and locally of finite presentation,
$X = S \times_{S'} X'$, and $Y = S \times_{S'} Y'$. Then
\begin{enumerate}
\item $f$ is flat if and only if $f'$ is flat,
\label{item-flat-fp-over-ft}
\item $f$ is an isomorphism if and only if $f'$ is an isomorphism,
\label{item-isomorphism-fp-over-ft}
\item $f$ is an open immersion if and only if $f'$ is an open immersion,
\label{item-open-immersion-fp-over-ft}
\item $f$ is quasi-compact if and only if $f'$ is quasi-compact,
\label{item-quasi-compact-fp-over-ft}
\item $f$ is universally closed if and only if $f'$ is universally closed,
\label{item-universally-closed-fp-over-ft}
\item $f$ is (quasi-)separated if and only if $f'$ is (quasi-)separated,
\label{item-separated-fp-over-ft}
\item $f$ is a monomorphism if and only if $f'$ is a monomorphism,
\label{item-monomorphism-fp-over-ft}
\item $f$ is surjective if and only if $f'$ is surjective,
\label{item-surjective-fp-over-ft}
\item $f$ is universally injective if and only if $f'$ is universally injective,
\label{item-universally-injective-fp-over-ft}
\item $f$ is affine if and only if $f'$ is affine,
\label{item-affine-fp-over-ft}
\item $f$ is locally quasi-finite if and only if $f'$ is locally quasi-finite,
\label{item-quasi-finite-fp-over-ft}
\item
\label{item-relative-dimension-d-fp-over-ft}
$f$ is locally of finite type of relative dimension $d$ if and only if
$f'$ is locally of finite type of relative dimension $d$,
\item $f$ is universally open if and only if $f'$ is universally open,
\label{item-universally-open-fp-over-ft}
\item $f$ is syntomic if and only if $f'$ is syntomic,
\label{item-syntomic-fp-over-ft}
\item $f$ is smooth if and only if $f'$ is smooth,
\label{item-smooth-fp-over-ft}
\item $f$ is unramified if and only if $f'$ is unramified,
\label{item-unramified-fp-over-ft}
\item $f$ is \'etale if and only if $f'$ is \'etale,
\label{item-etale-fp-over-ft}
\item $f$ is proper if and only if $f'$ is proper,
\label{item-proper-fp-over-ft}
\item $f$ is finite if and only if $f'$ is finite,
\label{item-finite-fp-over-ft}
\item
\label{item-finite-locally-free-fp-over-ft}
$f$ is finite locally free (of rank $d$) if and only if $f'$
is finite locally free (of rank $d$), and
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
The assumptions on $X$ and $Y$ mean that $f$ is the base change of
$f'$ by $X \to X'$.
The properties $\mathcal{P}$ listed in (1) -- (20) above are all stable
under base change, hence if $f'$ has property $\mathcal{P}$, then so
does $f$. See
Schemes, Lemmas \ref{schemes-lemma-base-change-immersion},
\ref{schemes-lemma-quasi-compact-preserved-base-change},
\ref{schemes-lemma-separated-permanence}, and
\ref{schemes-lemma-base-change-monomorphism}
and
Morphisms, Lemmas
\ref{morphisms-lemma-base-change-surjective},
\ref{morphisms-lemma-base-change-universally-injective},
\ref{morphisms-lemma-base-change-affine},
\ref{morphisms-lemma-base-change-quasi-finite},
\ref{morphisms-lemma-base-change-relative-dimension-d},
\ref{morphisms-lemma-base-change-syntomic},
\ref{morphisms-lemma-base-change-smooth},
\ref{morphisms-lemma-base-change-unramified},
\ref{morphisms-lemma-base-change-etale},
\ref{morphisms-lemma-base-change-proper},
\ref{morphisms-lemma-base-change-finite}, and
\ref{morphisms-lemma-base-change-finite-locally-free}.

\medskip\noindent
The interesting direction in each case is therefore to assume
that $f$ has the property and deduce that $f'$ has it too.
We make a couple of general remarks which we will use without further
mention in the arguments below.
(I) Let $W' \subset S'$ be an affine open and let $U' \subset X'$
and $V' \subset Y'$ be affine opens lying over $W'$ with $f'(U') \subset V'$.
Let $W' = \Spec(R')$ and denote $I \subset R'$ be the ideal
defining the closed subscheme $W' \cap S$. Say $U' = \Spec(B')$
and $V' = \Spec(A')$. Then we get a commutative diagram
$$
\xymatrix{
0 \ar[r] &
IB' \ar[r] &
B' \ar[r] &
B \ar[r] & 0 \\
0 \ar[r] &
IA' \ar[r] \ar[u] &
A' \ar[r] \ar[u] &
A \ar[r] \ar[u] & 0
}
$$
with exact rows.
(II) The morphisms $X \to X'$ and $Y \to Y'$ are universal homeomorphisms.
Hence the topology of the maps $f$ and $f'$ (after any base change) is
identical.
(III) If $f$ is flat, then $f'$ is flat and $Y' \to S'$ is flat at every
point in the image of $f'$, see
Lemma \ref{lemma-flatness-morphism-thickenings}.

\medskip\noindent
Ad (\ref{item-flat-fp-over-ft}). This is general remark (III).

\medskip\noindent
Ad (\ref{item-isomorphism-fp-over-ft}). Assume $f$ is an isomorphism.
Choose an affine open $V' \subset Y'$ and set $U' = (f')^{-1}(V')$.
Then $V = Y \cap V'$ is affine which implies that
$V \cong f^{-1}(V) = U = Y \times_{Y'} U'$ is affine. By
Lemma \ref{lemma-thickening-affine-scheme}
we see that $U'$ is affine. Thus we have a diagram as in the
general remark (I). By Algebra, Lemma
\ref{algebra-lemma-isomorphism-modulo-locally-nilpotent}
we see that $A' \to B'$ is an isomorphism, i.e., $U' \cong V'$.
Thus $f'$ is an isomorphism.

\medskip\noindent
Ad (\ref{item-open-immersion-fp-over-ft}). Assume $f$ is an open immersion.
Then $f$ is an isomorphism of $X$ with an open subscheme $V \subset Y$.
Let $V' \subset Y'$ be the open subscheme whose underlying topological
space is $V$. Then $f'$ is a map from $X'$ to $V'$ which is an isomorphism by
(\ref{item-isomorphism-fp-over-ft}). Hence $f'$ is an open immersion.

\medskip\noindent
Ad (\ref{item-quasi-compact-fp-over-ft}). Immediate from remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-universally-closed-fp-over-ft}). Immediate from remark (II). See
also Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-separated-fp-over-ft}). Note that
$X \times_Y X = Y \times_{Y'} (X' \times_{Y'} X')$ so that
$X' \times_{Y'} X'$ is a thickening of $X \times_Y X$.
Hence the topology of the maps $\Delta_{X/Y}$ and $\Delta_{X'/Y'}$
matches and we win. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-monomorphism-fp-over-ft}). Assume $f$ is a monomorphism.
Consider the diagonal morphism $\Delta_{X'/Y'} : X' \to X' \times_{Y'} X'$.
Observe that $X' \times_{Y'} X' \to S'$ is locally of finite type.
The base change of $\Delta_{X'/Y'}$ by $S \to S'$ is $\Delta_{X/Y}$
which is an isomorphism by assumption. By (\ref{item-isomorphism-fp-over-ft})
we conclude that $\Delta_{X'/Y'}$ is an isomorphism.

\medskip\noindent
Ad (\ref{item-surjective-fp-over-ft}). This is clear. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-universally-injective-fp-over-ft}).
Immediate from remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-affine-fp-over-ft}). Assume $f$ is affine.  Choose an
affine open $V' \subset Y'$ and set $U' = (f')^{-1}(V')$.
Then $V = Y \cap V'$ is affine which implies that
$U = Y \times_{Y'} U'$ is affine. By
Lemma \ref{lemma-thickening-affine-scheme}
we see that $U'$ is affine. Hence $f'$ is affine. See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-quasi-finite-fp-over-ft}). Follows from the fact that $f'$
is locally of finite type
(by Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}) and that
quasi-finiteness of a morphism of finite type can be checked on fibres, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize}.

\medskip\noindent
Ad (\ref{item-relative-dimension-d-fp-over-ft}).
Follows from general remark (II) and the fact that $f'$
is locally of finite type
(Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}).

\medskip\noindent
Ad (\ref{item-universally-open-fp-over-ft}).
Immediate from general remark (II). See also
Lemma \ref{lemma-thicken-property-morphisms} for a more general statement.

\medskip\noindent
Ad (\ref{item-syntomic-fp-over-ft}). Assume $f$ is syntomic. By
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
$f'$ is locally of finite presentation.
By general remark (III) $f'$ is flat. The fibres of $f'$ are the fibres
of $f$. Hence $f'$ is syntomic by
Morphisms, Lemma \ref{morphisms-lemma-syntomic-flat-fibres}.

\medskip\noindent
Ad (\ref{item-smooth-fp-over-ft}). Assume $f$ is smooth. By
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
$f'$ is locally of finite presentation.
By general remark (III) $f'$ is flat. The fibres of $f'$ are the
fibres of $f$. Hence $f'$ is smooth by
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat-smooth-fibres}.

\medskip\noindent
Ad (\ref{item-unramified-fp-over-ft}). Assume $f$ unramified. By
Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}
$f'$ is locally of finite type. The fibres of $f'$ are the fibres of $f$.
Hence $f'$ is unramified by
Morphisms, Lemma \ref{morphisms-lemma-unramified-etale-fibres}.

\medskip\noindent
Ad (\ref{item-etale-fp-over-ft}). Assume $f$ \'etale. By
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
$f'$ is locally of finite presentation.
By general remark (III) $f'$ is flat.
The fibres of $f'$ are the fibres of $f$. Hence $f'$ is \'etale by
Morphisms, Lemma \ref{morphisms-lemma-etale-flat-etale-fibres}.

\medskip\noindent
Ad (\ref{item-proper-fp-over-ft}). This follows from a combination of
(\ref{item-separated-fp-over-ft}), the fact that $f$ is locally
of finite type (Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}),
(\ref{item-quasi-compact-fp-over-ft}),
and (\ref{item-universally-closed-fp-over-ft}).

\medskip\noindent
Ad (\ref{item-finite-fp-over-ft}).
Combine (\ref{item-universally-closed-fp-over-ft}),
(\ref{item-affine-fp-over-ft}),
Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed},
the fact that $f$ is locally of finite type
(Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}), and
Morphisms, Lemma \ref{morphisms-lemma-finite-integral}.

\medskip\noindent
Ad (\ref{item-finite-locally-free-fp-over-ft}).
Assume $f$ finite locally free. By
(\ref{item-finite-fp-over-ft}) we see that $f'$ is finite.
By general remark (III) $f'$ is flat.
By Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
$f'$ is locally of finite presentation. Hence $f'$ is finite locally free by
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}.
\end{proof}

\begin{lemma}[Deformations of projective schemes]
\label{lemma-deform-projective}
Let $f : X \to S$ be a morphism of schemes which is proper, flat, and
of finite presentation. Let $\mathcal{L}$ be $f$-ample. Assume
$S$ is quasi-compact. There exists a $d_0 \geq 0$ such that
for every cartesian diagram
$$
\vcenter{
\xymatrix{
X \ar[r]_{i'} \ar[d]_f & X' \ar[d]^{f'} \\
S \ar[r]^i & S'
}
}
\quad\text{and}\quad
\begin{matrix}
\text{invertible }\mathcal{O}_{X'}\text{-module}\\
\mathcal{L}'\text{ with }\mathcal{L} \cong (i')^*\mathcal{L}'
\end{matrix}
$$
where $S \subset S'$ is a thickening and $f'$ is
proper, flat, of finite presentation we have
\begin{enumerate}
\item $R^p(f')_*(\mathcal{L}')^{\otimes d} = 0$
for all $p > 0$ and $d \geq d_0$,
\item $\mathcal{A}'_d = (f')_*(\mathcal{L}')^{\otimes d}$
is finite locally free for $d \geq d_0$,
\item $\mathcal{A}' =
\mathcal{O}_{S'} \oplus \bigoplus_{d \geq d_0} \mathcal{A}'_d$
is a quasi-coherent $\mathcal{O}_{S'}$-algebra of finite presentation,
\item there is a canonical isomorphism
$r' : X' \to \underline{\text{Proj}}_{S'}(\mathcal{A}')$, and
\item there is a canonical isomorphism
$\theta' : (r')^*\mathcal{O}_{\underline{\text{Proj}}_{S'}(\mathcal{A}')}(1)
\to \mathcal{L}'$.
\end{enumerate}
The construction of $\mathcal{A}'$, $r'$, $\theta'$
is functorial in the data $(X', S', i, i', f', \mathcal{L}')$.
\end{lemma}

\begin{proof}
We first describe the maps $r'$ and $\theta'$.
Observe that $\mathcal{L}'$ is $f'$-ample, see
Lemma \ref{lemma-thicken-property-relatively-ample}.
There is a canonical map of quasi-coherent graded
$\mathcal{O}_{S'}$-algebras
$\mathcal{A}' \to \bigoplus_{d \geq 0} (f')_*(\mathcal{L}')^{\otimes d}$
which is an isomorphism in degrees $\geq d_0$.
Hence this induces an isomorphism on relative Proj
compatible with the Serre twists of the structure sheaf, see
Constructions, Lemma
\ref{constructions-lemma-eventual-iso-graded-rings-map-relative-proj}.
Hence we get the morphism $r'$ by
Morphisms, Lemma \ref{morphisms-lemma-characterize-relatively-ample}
(which in turn appeals to the construction given in
Constructions, Lemma
\ref{constructions-lemma-invertible-map-into-relative-proj})
and it is an isomorphism by
Morphisms, Lemma \ref{morphisms-lemma-proper-ample-is-proj}.
We get the map $\theta'$ from Constructions, Lemma
\ref{constructions-lemma-invertible-map-into-relative-proj}.
By Properties, Lemma \ref{properties-lemma-ample-gcd-is-one}
we find that $\theta'$ is an isomorphism
(this also uses that the morphism $r'$ over affine
opens of $S'$ is the same as the morphism from
Properties, Lemma \ref{properties-lemma-map-into-proj}
as is explained in the proof
of Morphisms, Lemma \ref{morphisms-lemma-proper-ample-is-proj}).

\medskip\noindent
Assuming the vanishing and local freeness stated in parts
(1) and (2), the functoriality of the construction can be seen as follows.
Suppose that $h : T \to S'$ is a morphism of schemes, denote
$f_T : X'_T \to T$ the base change of $f'$ and
$\mathcal{L}_T$ the pullback of $\mathcal{L}$ to $X'_T$.
By cohomology and base change
(as formulated in Derived Categories of Schemes,
Lemma \ref{perfect-lemma-compare-base-change} for example)
we have the corresponding vanishing over $T$ and moreover
$h^*\mathcal{A}'_d = f_{T, *}\mathcal{L}_T^{\otimes d}$
(and thus the local freeness of pushforwards as well
as the finite generation of the corresponding graded
$\mathcal{O}_T$-algebra $\mathcal{A}_T$).
Hence the morphism
$r_T : X_T \to
\underline{\text{Proj}}_T(\bigoplus f_{T, *}\mathcal{L}_T^{\otimes d})$
is simply the base change of $r'$ to $T$ and the pullback of
$\theta'$ is the map $\theta_T$.

\medskip\noindent
Having said all of the above, we see that it suffices to prove
(1), (2), and (3). Pick $d_0$ such that
$R^pf_*\mathcal{L}^{\otimes d} = 0$ for all $d \geq d_0$ and $p > 0$, see
Cohomology of Schemes, Lemma \ref{coherent-lemma-coherent-proper-ample}.
We claim that $d_0$ works.

\medskip\noindent
By cohomology and base change
(Derived Categories of Schemes,
Lemma \ref{perfect-lemma-flat-proper-perfect-direct-image-general})
we see that $E'_d = Rf'_*(\mathcal{L}')^{\otimes d}$
is a perfect object of $D(\mathcal{O}_{S'})$
and its formation commutes with arbitrary base change.
In particular, $E_d = Li^*E'_d = Rf_*\mathcal{L}^{\otimes d}$.
By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-vanishing-implies-locally-free}
we see that for $d \geq d_0$ the complex $E_d$ is isomorphic to
the finite locally free $\mathcal{O}_S$-module
$f_*\mathcal{L}^{\otimes d}$ placed in
cohomological degree $0$. Then by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-open-where-cohomology-in-degree-i-rank-r}
we conclude that $E'_d$ is isomorphic to a finite locally free
module placed in cohomological degree $0$.
Of course this means that $E'_d = \mathcal{A}'_d[0]$,
that $R^pf'_*(\mathcal{L}')^{\otimes d} = 0$ for $p > 0$,
and that $\mathcal{A}'_d$ is finite locally free.
This proves (1) and (2).

\medskip\noindent
The last thing we have to show is finite presentation of
$\mathcal{A}'$ as a sheaf of $\mathcal{O}_{S'}$-algebras
(this notion was introduced in Properties, Section
\ref{properties-section-extending-quasi-coherent-sheaves}).
Let $U' = \Spec(R') \subset S'$ be an affine open.
Then $A' = \mathcal{A}'(U')$ is a graded $R'$-algebra
whose graded parts are finite projective $R'$-modules.
We have to show that $A'$ is a finitely presented $R'$-algebra.
We will prove this by reduction to the Noetherian case.
Namely, we can find a finite type $\mathbf{Z}$-subalgebra
$R'_0 \subset R'$ and a pair\footnote{With the same properties
as those enjoyed by $X' \to S'$ and $\mathcal{L}'$, i.e.,
$X'_0 \to \Spec(R'_0)$ is flat and proper and $\mathcal{L}'_0$
is ample.} $(X'_0, \mathcal{L}'_0)$ over $R'_0$
whose base change is $(X'_{U'}, \mathcal{L}'|_{X'_{U'}})$, see
Limits, Lemmas
\ref{limits-lemma-descend-modules-finite-presentation},
\ref{limits-lemma-descend-invertible-modules},
\ref{limits-lemma-eventually-proper},
\ref{limits-lemma-descend-flat-finite-presentation}, and
\ref{limits-lemma-limit-ample}.
Cohomology of Schemes, Lemma \ref{coherent-lemma-coherent-proper-ample}
implies
$A'_0 = \bigoplus_{d \geq 0} H^0(X'_0, (\mathcal{L}'_0)^{\otimes d})$
is a finitely generated graded $R'_0$-algebra and implies
there exists a $d'_0$ such that
$H^p(X'_0, (\mathcal{L}'_0)^{\otimes d}) = 0$, $p > 0$ for $d \geq d'_0$.
By the arguments given above applied to $X'_0 \to \Spec(R'_0)$ and
$\mathcal{L}'_0$ we see that $(A'_0)_d$ is a finite projective $R'_0$-module
and that
$$
A'_d = \mathcal{A}'_d(U') =
H^0(X'_{U'}, (\mathcal{L}')^{\otimes d}|_{X'_{U'}}) =
H^0(X'_0, (\mathcal{L}'_0)^{\otimes d}) \otimes_{R'_0} R' =
(A'_0)_d \otimes_{R'_0} R'
$$
for $d \geq d'_0$. Now a small twist in the argument is that we
don't know that we can choose $d'_0$ equal to $d_0$\footnote{Actually,
one can reduce to this case by doing more limit arguments.}. To
get around this we use the following sequence of arguments to finish
the proof:
\begin{enumerate}
\item[(a)] The algebra
$B = R'_0 \oplus \bigoplus_{d \geq \max(d_0, d'_0)} (A'_0)_d$
is an $R'_0$-algebra of finite type: apply
the Artin-Tate lemma to $B \subset A'_0$, see
Algebra, Lemma \ref{algebra-lemma-Artin-Tate}.
\item[(b)] As $R'_0$ is Noetherian we see that
$B$ is an $R'_0$-algebra of finite presentation.
\item[(c)] By right exactness of tensor product we see that
$B \otimes_{R'_0} R'$ is an $R'$-algebra of finite presentation.
\item[(d)] By the displayed equalities this exactly says that
$C = R' \oplus \bigoplus_{d \geq \max(d_0, d'_0)} A'_d$
is an $R'$-algebra of finite presentation.
\item[(e)] The quotient $A'/C$ is the direct sum of the finite
projective $R'$-modules $A'_d$, $d_0 \leq d \leq \max(d_0, d'_0)$,
hence finitely presented as $R'$-module.
\item[(f)] The quotient $A'/C$ is finitely presented
as a $C$-module by Algebra, Lemma
\ref{algebra-lemma-finitely-presented-over-subring}.
\item[(g)] Thus $A'$ is finitely presented as a $C$-module by
Algebra, Lemma \ref{algebra-lemma-extension}.
\item[(h)] By Algebra, Lemma \ref{algebra-lemma-finite-finite-type}
this implies $A'$ is finitely presented as a $C$-algebra.
\item[(i)] Finally, by
Algebra, Lemma \ref{algebra-lemma-compose-finite-type}
applied to $R' \to C \to A'$
this implies $A'$ is finitely presented as an $R'$-algebra.
\end{enumerate}
This finishes the proof.
\end{proof}









\section{Formally smooth morphisms}
\label{section-formally-smooth}

\noindent
Michael Artin's position on differential criteria of smoothness (e.g.,
Morphisms, Lemma \ref{morphisms-lemma-smooth-at-point}) is that they are
basically useless (in practice). In this section we introduce the
notion of a formally smooth morphism $X \to S$. Such a morphism is
characterized by the property that $T$-valued points of $X$ lift
to infinitesimal thickenings of $T$ provided $T$ is affine.
The main result is that a morphism which is formally smooth and
locally of finite presentation is smooth, see
Lemma \ref{lemma-smooth-formally-smooth}.
It turns out that this criterion is often easier to use than the
differential criteria mentioned above.

\medskip\noindent
Recall that a ring map $R \to A$ is called {\it formally smooth}
(see Algebra, Definition \ref{algebra-definition-formally-smooth})
if for every commutative solid diagram
$$
\xymatrix{
A \ar[r] \ar@{-->}[rd] & B/I \\
R \ar[r] \ar[u] & B \ar[u]
}
$$
where $I \subset B$ is an ideal of square zero, a dotted
arrow exists which makes the diagram commute. This motivates
the following analogue for morphisms of schemes.

\begin{definition}
\label{definition-formally-smooth}
Let $f : X \to S$ be a morphism of schemes.
We say $f$ is {\it formally smooth} if given any solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l] \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
where $T \subset T'$ is a first order thickening of affine schemes over $S$
there exists a dotted arrow making the diagram commute.
\end{definition}

\noindent
In the cases of formally unramified and formally \'etale morphisms
the condition that $T'$ be affine could be dropped, see
Lemmas \ref{lemma-formally-unramified-not-affine} and
\ref{lemma-formally-etale-not-affine}.
This is no longer true in the case of formally smooth morphisms.
In fact, a slightly more natural condition would be that we should be
able to fill in the dotted arrow Zariski locally on $T'$.
In fact, analyzing the proof of
Lemma \ref{lemma-formally-smooth}
shows that this would be equivalent to the definition as it currently
stands. In particular, the being formally smooth is
Zariski local on the source (and in fact it is smooth local on the soure,
insert future reference here).

\begin{lemma}
\label{lemma-composition-formally-smooth}
A composition of formally smooth morphisms is formally smooth.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-base-change-formally-smooth}
A base change of a formally smooth morphism is formally smooth.
\end{lemma}

\begin{proof}
Omitted, but see Algebra, Lemma \ref{algebra-lemma-base-change-fs}
for the algebraic version.
\end{proof}

\begin{lemma}
\label{lemma-formally-etale-unramified-smooth}
Let $f : X \to S$ be a morphism of schemes.
Then $f$ is formally \'etale if and only if
$f$ is formally smooth and formally unramified.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-formally-smooth-on-opens}
Let $f : X \to S$ be a morphism of schemes.
Let $U \subset X$ and $V \subset S$ be open subschemes such that
$f(U) \subset V$. If $f$ is formally smooth, so is $f|_U : U \to V$.
\end{lemma}

\begin{proof}
Consider a solid diagram
$$
\xymatrix{
U \ar[d]_{f|_U} & T \ar[d]^i \ar[l]^a \\
V & T' \ar[l] \ar@{-->}[lu]
}
$$
as in Definition \ref{definition-formally-smooth}. If $f$ is formally
smooth, then there exists an $S$-morphism $a' : T' \to X$ such that
$a'|_T = a$. Since the underlying sets of $T$ and $T'$ are the same
we see that $a'$ is a morphism into $U$ (see Schemes, Section
\ref{schemes-section-open-immersion}). And it clearly is a $V$-morphism
as well. Hence the dotted arrow above as desired.
\end{proof}

\begin{lemma}
\label{lemma-affine-formally-smooth}
Let $f : X \to S$ be a morphism of schemes.
Assume $X$ and $S$ are affine.
Then $f$ is formally smooth if and only if
$\mathcal{O}_S(S) \to \mathcal{O}_X(X)$ is a formally smooth
ring map.
\end{lemma}

\begin{proof}
This is immediate from the definitions
(Definition \ref{definition-formally-smooth} and
Algebra, Definition \ref{algebra-definition-formally-smooth})
by the equivalence of categories of rings and affine schemes,
see
Schemes, Lemma \ref{schemes-lemma-category-affine-schemes}.
\end{proof}

\noindent
The following lemma is the main result of this section. It is a victory of the
functorial point of view in that it implies (combined with
Limits,
Proposition \ref{limits-proposition-characterize-locally-finite-presentation})
that we can recognize whether a morphism $f : X \to S$ is smooth in terms of
``simple'' properties of the functor $h_X : \Sch/S \to \textit{Sets}$.

\begin{lemma}[Infinitesimal lifting criterion]
\label{lemma-smooth-formally-smooth}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item The morphism $f$ is smooth, and
\item the morphism $f$ is locally of finite presentation and
formally smooth.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $f : X \to S$ is locally of finite presentation and formally smooth.
Consider a pair of affine opens $\Spec(A) = U \subset X$ and
$\Spec(R) = V \subset S$
such that $f(U) \subset V$. By Lemma \ref{lemma-formally-smooth-on-opens}
we see that $U \to V$ is formally smooth. By Lemma
\ref{lemma-affine-formally-smooth} we see that $R \to A$ is formally
smooth. By
Morphisms, Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}
we see that $R \to A$ is of finite presentation.
By Algebra, Proposition \ref{algebra-proposition-smooth-formally-smooth}
we see that $R \to A$ is smooth.
Hence by the definition of a smooth morphism we see that $X \to S$ is smooth.

\medskip\noindent
Conversely, assume that $f : X \to S$ is smooth. Consider a solid commutative
diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l]^a \\
S & T' \ar[l] \ar@{-->}[lu]
}
$$
as in Definition \ref{definition-formally-smooth}.
We will show the dotted arrow exists thereby
proving that $f$ is formally smooth.

\medskip\noindent
Let $\mathcal{F}$ be the sheaf of sets on $T'$ of Lemma \ref{lemma-sheaf}
in the special case discussed in Remark \ref{remark-special-case}.
Let
$$
\mathcal{H} =
\SheafHom_{\mathcal{O}_T}(a^*\Omega_{X/S}, \mathcal{C}_{T/T'})
$$
be the sheaf of $\mathcal{O}_T$-modules with action
$\mathcal{H} \times \mathcal{F} \to \mathcal{F}$ as in
Lemma \ref{lemma-action-sheaf}. Our goal is simply
to show that $\mathcal{F}(T) \not = \emptyset$. In other words we
are trying to show that $\mathcal{F}$ is a trivial $\mathcal{H}$-torsor
on $T$ (see Cohomology, Section \ref{cohomology-section-h1-torsors}).
There are two steps: (I) To show that $\mathcal{F}$ is a torsor
we have to show that $\mathcal{F}_t \not = \emptyset$ for all $t \in T$ (see
Cohomology, Definition \ref{cohomology-definition-torsor}).
(II) To show that $\mathcal{F}$ is the trivial torsor it suffices
to show that $H^1(T, \mathcal{H}) = 0$ (see
Cohomology, Lemma \ref{cohomology-lemma-torsors-h1} --
we may use either cohomology
of $\mathcal{H}$ as an abelian sheaf or as an $\mathcal{O}_T$-module,
see Cohomology, Lemma \ref{cohomology-lemma-modules-abelian}).

\medskip\noindent
First we prove (I). To see this, for every $t \in T$ we can
choose an affine open $U \subset T$ neighbourhood of $t$
such that $a(U)$ is contained
in an affine open $\Spec(A) = W \subset X$
which maps to an affine open $\Spec(R) = V \subset S$.
By Morphisms, Lemma \ref{morphisms-lemma-smooth-characterize}
the ring map $R \to A$ is smooth.
Hence by Algebra, Proposition \ref{algebra-proposition-smooth-formally-smooth}
the ring map $R \to A$ is formally smooth.
Lemma \ref{lemma-affine-formally-smooth}
in turn implies that $W \to V$ is formally smooth.
Hence we can lift $a|_U : U \to W$ to a $V$-morphism
$a' : U' \to W \subset X$ showing that $\mathcal{F}(U) \not = \emptyset$.

\medskip\noindent
Finally we prove (II).
By Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-differentials}
we see that $\Omega_{X/S}$ is of finite presentation
(it is even finite locally free by
Morphisms, Lemma \ref{morphisms-lemma-smooth-omega-finite-locally-free}).
Hence $a^*\Omega_{X/S}$ is of finite presentation (see
Modules, Lemma \ref{modules-lemma-pullback-finite-presentation}).
Hence the sheaf
$\mathcal{H} =
\SheafHom_{\mathcal{O}_T}(a^*\Omega_{X/S}, \mathcal{C}_{T/T'})$
is quasi-coherent by the discussion in
Schemes, Section \ref{schemes-section-quasi-coherent}.
Thus by Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherent-affine-cohomology-zero}
we have $H^1(T, \mathcal{H}) = 0$ as desired.
\end{proof}

\noindent
Locally projective quasi-coherent modules are defined in
Properties, Section \ref{properties-section-locally-projective}.

\begin{lemma}
\label{lemma-formally-smooth-sheaf-differentials}
Let $f : X \to Y$ be a formally smooth morphism of schemes.
Then $\Omega_{X/Y}$ is locally projective on $X$.
\end{lemma}

\begin{proof}
Choose $U \subset X$ and $V \subset Y$ affine open such that
$f(U) \subset V$. By
Lemma \ref{lemma-formally-smooth-on-opens}
$f|_U : U \to V$ is formally smooth. Hence
$\Gamma(V, \mathcal{O}_V) \to \Gamma(U, \mathcal{O}_U)$ is
a formally smooth ring map, see
Lemma \ref{lemma-affine-formally-smooth}.
Hence by
Algebra, Lemma \ref{algebra-lemma-characterize-formally-smooth-again}
the $\Gamma(U, \mathcal{O}_U)$-module
$\Omega_{\Gamma(U, \mathcal{O}_U)/\Gamma(V, \mathcal{O}_V)}$
is projective. Hence $\Omega_{U/V}$ is locally projective, see
Properties, Section \ref{properties-section-locally-projective}.
\end{proof}

\begin{lemma}
\label{lemma-h1-is-zero}
Let $T$ be an affine scheme. Let $\mathcal{F}$, $\mathcal{G}$ be quasi-coherent
$\mathcal{O}_T$-modules. Consider
$\mathcal{H} = \SheafHom_{\mathcal{O}_T}(\mathcal{F}, \mathcal{G})$.
If $\mathcal{F}$ is locally projective, then $H^1(T, \mathcal{H}) = 0$.
\end{lemma}

\begin{proof}
By the definition of a locally projective sheaf on a scheme (see
Properties, Definition \ref{properties-definition-locally-projective})
we see that $\mathcal{F}$ is a direct summand of a free
$\mathcal{O}_T$-module. Hence we may assume that
$\mathcal{F} = \bigoplus_{i \in I} \mathcal{O}_T$ is a free module.
In this case $\mathcal{H} = \prod_{i \in I} \mathcal{G}$ is
a product of quasi-coherent modules. By
Cohomology, Lemma \ref{cohomology-lemma-cohomology-products}
we conclude that $H^1 = 0$ because the cohomology of a quasi-coherent sheaf
on an affine scheme is zero, see Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherent-affine-cohomology-zero}.
\end{proof}

\begin{lemma}
\label{lemma-formally-smooth}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent:
\begin{enumerate}
\item $f$ is formally smooth,
\item for every $x \in X$ there exist opens $x \in U \subset X$ and
$f(x) \in V \subset Y$ with $f(U) \subset V$ such that
$f|_U : U \to V$ is formally smooth,
\item for every pair of affine opens $U \subset X$ and $V \subset Y$
with $f(U) \subset V$ the ring map $\mathcal{O}_Y(V) \to \mathcal{O}_X(U)$
is formally smooth, and
\item there exists an affine open covering $Y = \bigcup V_j$ and
for each $j$ an affine open covering $f^{-1}(V_j) = \bigcup U_{ji}$
such that $\mathcal{O}_Y(V) \to \mathcal{O}_X(U)$ is a formally smooth
ring map for all $j$ and $i$.
\end{enumerate}
\end{lemma}

\begin{proof}
The implications (1) $\Rightarrow$ (2),
(1) $\Rightarrow$ (3), and (2) $\Rightarrow$ (4) follow from
Lemma \ref{lemma-formally-smooth-on-opens}.
The implication (3) $\Rightarrow$ (4) is immediate.

\medskip\noindent
Assume (4). The proof that $f$ is formally smooth is the same
as the second part of the proof of Lemma \ref{lemma-smooth-formally-smooth}.
Consider a solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & T \ar[d]^i \ar[l]^a \\
Y & T' \ar[l] \ar@{-->}[lu]
}
$$
as in Definition \ref{definition-formally-smooth}.
We will show the dotted arrow exists thereby
proving that $f$ is formally smooth.
Let $\mathcal{F}$ be the sheaf of sets on $T'$ of
Lemma \ref{lemma-sheaf} as in the special case discussed in
Remark \ref{remark-special-case}.
Let
$$
\mathcal{H} =
\SheafHom_{\mathcal{O}_T}(a^*\Omega_{X/Y}, \mathcal{C}_{T/T'})
$$
be the sheaf of $\mathcal{O}_T$-modules on $T$
with action $\mathcal{H} \times \mathcal{F} \to \mathcal{F}$ as in
Lemma \ref{lemma-action-sheaf}.
The action $\mathcal{H} \times \mathcal{F} \to \mathcal{F}$
turns $\mathcal{F}$ into a pseudo $\mathcal{H}$-torsor, see
Cohomology, Definition \ref{cohomology-definition-torsor}.
Our goal is to show that $\mathcal{F}$ is a trivial $\mathcal{H}$-torsor.
There are two steps: (I) To show that $\mathcal{F}$ is a torsor
we have to show that $\mathcal{F}$ locally has a
section. (II) To show that $\mathcal{F}$ is the trivial torsor
it suffices to show that $H^1(T, \mathcal{H}) = 0$, see
Cohomology, Lemma \ref{cohomology-lemma-torsors-h1}.

\medskip\noindent
First we prove (I). To see this, for every $t \in T$ we can
choose an affine open $W \subset T$ neighbourhood of $t$
such that $a(W)$ is contained in $U_{ji}$ for some $i, j$.
Let $W' \subset T'$ be the corresponding open subscheme.
By assumption (4) we can lift $a|_W : W \to U_{ji}$
to a $V_j$-morphism $a' : W' \to U_{ji}$ showing that
$\mathcal{F}(W')$ is nonempty.

\medskip\noindent
Finally we prove (II). By
Lemma \ref{lemma-formally-smooth-sheaf-differentials}
we see that $\Omega_{U_{ji}/V_j}$ locally projective.
Hence $\Omega_{X/Y}$ is locally projective, see
Properties, Lemma \ref{properties-lemma-locally-projective}.
Hence $a^*\Omega_{X/Y}$ is locally projective, see
Properties, Lemma \ref{properties-lemma-locally-projective-pullback}.
Hence
$$
H^1(T, \mathcal{H}) =
H^1(T, \SheafHom_{\mathcal{O}_T}(a^*\Omega_{X/Y}, \mathcal{C}_{T/T'}) = 0
$$
by
Lemma \ref{lemma-h1-is-zero}
as desired.
\end{proof}

\begin{lemma}
\label{lemma-triangle-differentials-formally-smooth}
Let $f : X \to Y$, $g : Y \to S$ be morphisms of schemes.
Assume $f$ is formally smooth. Then
$$
0 \to f^*\Omega_{Y/S} \to \Omega_{X/S} \to \Omega_{X/Y} \to 0
$$
(see
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials})
is short exact.
\end{lemma}

\begin{proof}
The algebraic version of this lemma is the following:
Given ring maps $A \to B \to C$ with $B \to C$ formally smooth, then
the sequence
$$
0 \to C \otimes_B \Omega_{B/A} \to \Omega_{C/A} \to \Omega_{C/B} \to 0
$$
of
Algebra, Lemma \ref{algebra-lemma-exact-sequence-differentials}
is exact. This is
Algebra, Lemma \ref{algebra-lemma-ses-formally-smooth}.
\end{proof}

\begin{lemma}
\label{lemma-differentials-formally-unramified-formally-smooth}
Let $h : Z \to X$ be a formally unramified morphism of schemes over $S$.
Assume that $Z$ is formally smooth over $S$. Then the
canonical exact sequence
$$
0 \to \mathcal{C}_{Z/X} \to h^*\Omega_{X/S} \to \Omega_{Z/S} \to 0
$$
of
Lemma \ref{lemma-universally-unramified-differentials-sequence}
is short exact.
\end{lemma}

\begin{proof}
Let $Z \to Z'$ be the universal first order thickening of $Z$ over $X$.
From the proof of
Lemma \ref{lemma-universally-unramified-differentials-sequence}
we see that our sequence is identified with the sequence
$$
\mathcal{C}_{Z/Z'} \to \Omega_{Z'/S} \otimes \mathcal{O}_Z \to
\Omega_{Z/S} \to 0.
$$
Since $Z \to S$ is formally smooth we can locally on $Z'$ find
a left inverse $Z' \to Z$ over $S$ to the inclusion map $Z \to Z'$.
Thus the sequence is locally split, see
Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion-section}.
\end{proof}

\begin{lemma}
\label{lemma-two-unramified-morphisms-formally-smooth}
Let
$$
\xymatrix{
Z \ar[r]_i \ar[rd]_j & X \ar[d]^f \\
& Y
}
$$
be a commutative diagram of schemes where $i$ and $j$ are formally
unramified and $f$ is formally smooth. Then the canonical exact sequence
$$
0 \to
\mathcal{C}_{Z/Y} \to
\mathcal{C}_{Z/X} \to
i^*\Omega_{X/Y} \to 0
$$
of
Lemma \ref{lemma-two-unramified-morphisms}
is exact and locally split.
\end{lemma}

\begin{proof}
Denote $Z \to Z'$ the universal first order thickening of $Z$ over $X$.
Denote $Z \to Z''$ the universal first order thickening of $Z$ over $Y$.
By
Lemma \ref{lemma-universally-unramified-differentials-sequence}
here is a canonical morphism $Z' \to Z''$ so that we have a commutative
diagram
$$
\xymatrix{
Z \ar[r]_{i'} \ar[rd]_{j'} & Z' \ar[r]_a \ar[d]^k & X \ar[d]^f \\
& Z'' \ar[r]^b & Y
}
$$
In the proof of
Lemma \ref{lemma-two-unramified-morphisms}
we identified the sequence above with the sequence
$$
\mathcal{C}_{Z/Z''} \to
\mathcal{C}_{Z/Z'} \to
(i')^*\Omega_{Z'/Z''} \to 0
$$
Let $U'' \subset Z''$ be an affine open. Denote $U \subset Z$ and
$U' \subset Z'$ the corresponding affine open subschemes.
As $f$ is formally smooth there exists a morphism $h : U'' \to X$
which agrees with $i$ on $U$ and such that $f \circ h$ equals $b|_{U''}$.
Since $Z'$ is the universal first order thickening we obtain a unique
morphism $g : U'' \to Z'$ such that $g = a \circ h$. The universal
property of $Z''$ implies that $k \circ g$ is the inclusion map
$U'' \to Z''$. Hence $g$ is a left inverse to $k$. Picture
$$
\xymatrix{
U \ar[d] \ar[r] & Z' \ar[d]^k \\
U'' \ar[r] \ar[ru]^g & Z''
}
$$
Thus $g$ induces a map $\mathcal{C}_{Z/Z'}|_U \to \mathcal{C}_{Z/Z''}|_U$
which is a left inverse to the map
$\mathcal{C}_{Z/Z''} \to \mathcal{C}_{Z/Z'}$ over $U$.
\end{proof}



































\section{Smoothness over a Noetherian base}
\label{section-smooth-Noetherian}

\noindent
It turns out that if the base is Noetherian then we can get away with
less in the formulation of formal smoothness. In some sense the following
lemmas are the beginning of deformation theory.

\begin{lemma}
\label{lemma-lifting-along-artinian-at-point}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$.
Assume that $S$ is locally Noetherian and $f$ locally of finite type.
The following are equivalent:
\begin{enumerate}
\item $f$ is smooth at $x$,
\item for every solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & \Spec(B) \ar[d]^i \ar[l]^-\alpha \\
S & \Spec(B') \ar[l]_-{\beta} \ar@{-->}[lu]
}
$$
where $B' \to B$ is a surjection of local rings with
$\Ker(B' \to B)$ of square zero, and $\alpha$ mapping the
closed point of $\Spec(B)$ to $x$ there exists
a dotted arrow making the diagram commute,
\item same as in (2) but with $B' \to B$ ranging over small
extensions (see Algebra, Definition \ref{algebra-definition-small-extension}),
and
\item same as in (2) but with $B' \to B$ ranging over small
extensions such that $\alpha$ induces an isomorphism
$\kappa(x) \to \kappa(\mathfrak m)$ where $\mathfrak m \subset B$
is the maximal ideal.
\end{enumerate}
\end{lemma}

\begin{proof}
Choose an affine neighbourhood $V \subset S$ of $f(x)$ and choose an
affine neighbourhood $U \subset X$ of $x$ such that $f(U) \subset V$.
For any ``test'' diagram as in (2) the morphism $\alpha$ will map
$\Spec(B)$ into $U$ and the morphism $\beta$ will map $\Spec(B')$
into $V$ (see Schemes, Section \ref{schemes-section-points}).
Hence the lemma reduces to the morphism $f|_U : U \to V$ of affines.
(Indeed, $V$ is Noetherian and $f|_U$ is of finite type, see
Properties, Lemma \ref{properties-lemma-locally-Noetherian} and
Morphisms, Lemma \ref{morphisms-lemma-locally-finite-type-characterize}.)
In this affine case the lemma is identical to
Algebra, Lemma \ref{algebra-lemma-smooth-test-artinian}.
\end{proof}

\noindent
Sometimes it is useful to know that one only needs to check the
lifting criterion for small extensions ``centered'' at points
of finite type (see
Morphisms, Section \ref{morphisms-section-points-finite-type}).

\begin{lemma}
\label{lemma-lifting-along-artinian}
Let $f : X \to S$ be a morphism of schemes.
Assume that $S$ is locally Noetherian and $f$ locally of finite type.
The following are equivalent:
\begin{enumerate}
\item $f$ is smooth,
\item for every solid commutative diagram
$$
\xymatrix{
X \ar[d]_f & \Spec(B) \ar[d]^i \ar[l]^-\alpha \\
S & \Spec(B') \ar[l]_-{\beta} \ar@{-->}[lu]
}
$$
where $B' \to B$ is a small extension of Artinian local rings
and $\beta$ of finite type (!) there exists a dotted arrow making
the diagram commute.
\end{enumerate}
\end{lemma}

\begin{proof}
If $f$ is smooth, then the infinitesimal lifting criterion
(Lemma \ref{lemma-smooth-formally-smooth}) says
$f$ is formally smooth and (2) holds.

\medskip\noindent
Assume (2). The set of points $x \in X$ where $f$ is not smooth
forms a closed subset $T$ of $X$. By the discussion in Morphisms,
Section \ref{morphisms-section-points-finite-type}, if $T \not = \emptyset$
there exists a point $x \in T \subset X$ such that the morphism
$$
\Spec(\kappa(x)) \to X \to S
$$
is of finite type (namely, pick any point $x$ of $T$ which is closed
in an affine open of $X$). By
Morphisms, Lemma \ref{morphisms-lemma-artinian-finite-type} given any
local Artinian ring $B'$ with residue field $\kappa(x)$ then any
morphism $\beta : \Spec(B') \to S$ is of finite type. Thus
we see that all the diagrams used in
Lemma \ref{lemma-lifting-along-artinian-at-point} (4) correspond
to diagrams as in the current lemma (2). Whence $X \to S$ is smooth
a $x$ a contradiction.
\end{proof}

\noindent
Here is a useful application.

\begin{lemma}
\label{lemma-check-smoothness-on-infinitesimal-nbhds}
Let $f : X \to S$ be a finite type morphism of locally Noetherian schemes.
Let $Z \subset S$ be a closed subscheme with $n$th infinitesimal
neighbourhood $Z_n \subset S$. Set $X_n = Z_n \times_S X$.
\begin{enumerate}
\item If $X_n \to Z_n$ is smooth for all $n$, then $f$
is smooth at every point of $f^{-1}(Z)$.
\item If $X_n \to Z_n$ is \'etale for all $n$, then $f$
is \'etale at every point of $f^{-1}(Z)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $X_n \to Z_n$ is smooth for all $n$.
Let $x \in X$ be a point lying over a point of $Z$.
Given a small extension $B' \to B$ and morphisms $\alpha$, $\beta$ as in
Lemma \ref{lemma-lifting-along-artinian-at-point} part (3)
the maximal ideal of $B'$ is nilpotent (as $B'$ is Artinian)
and hence the morphism $\beta$ factors through $Z_n$ and $\alpha$ factors
through $X_n$ for a suitable $n$. Thus the lifting property for
$X_n \to Z_n$ kicks in to get the desired dotted arrow in the diagram.
This proves (1). Part (2) follows from (1) and the fact that a morphism
is \'etale if and only if it is smooth of relative dimension $0$.
\end{proof}

\begin{lemma}
\label{lemma-check-flatness-on-infinitesimal-nbhds}
Let $f : X \to S$ be a morphism of locally Noetherian schemes.
Let $Z \subset S$ be a closed subscheme with $n$th infinitesimal
neighbourhood $Z_n \subset S$. Set $X_n = Z_n \times_S X$.
If $X_n \to Z_n$ is flat for all $n$, then $f$
is flat at every point of $f^{-1}(Z)$.
\end{lemma}

\begin{proof}
This is a translation of Algebra, Lemma \ref{algebra-lemma-flat-module-powers}
into the language of schemes.
\end{proof}








\section{The naive cotangent complex}
\label{section-netherlander}

\noindent
This section is the continuation of
Modules, Section \ref{modules-section-netherlander}
which in turn continues the discussion in
Algebra, Section \ref{algebra-section-netherlander}.

\begin{definition}
\label{definition-netherlander}
Let $f : X \to Y$ be a morphism of schemes.
The {\it naive cotangent complex of $f$}
is the complex defined in Modules, Definition
\ref{modules-definition-cotangent-complex-morphism-ringed-topoi}.
Notation: $\NL_f$ or $\NL_{X/Y}$.
\end{definition}

\begin{lemma}
\label{lemma-NL-affine}
Let $f : X \to Y$ be a morphism of schemes. Let
$\Spec(A) = U \subset X$ and $\Spec(R) = V \subset S$
be affine opens with $f(U) \subset V$.
There is a canonical map
$$
\widetilde{\NL_{A/R}} \longrightarrow \NL_{X/Y}|_U
$$
of complexes which is an isomorphism in $D(\mathcal{O}_U)$.
\end{lemma}

\begin{proof}
From the construction of $\NL_{X/Y}$ in
Modules, Section \ref{modules-section-netherlander}
we see there is a canonical map of complexes
$\NL_{\mathcal{O}_X(U)/f^{-1}\mathcal{O}_Y(U)} \to \NL_{X/Y}(U)$
of $A = \mathcal{O}_X(U)$-modules, which is compatible
with further restrictions. Using the canonical map
$R \to f^{-1}\mathcal{O}_Y(U)$ we obtain a canonical map
$\NL_{A/R} \to \NL_{\mathcal{O}_X(U)/f^{-1}\mathcal{O}_Y(U)}$
of complexes of $A$-modules.
Using the universal property of the $\widetilde{\ }$
functor (see Schemes, Lemma \ref{schemes-lemma-compare-constructions})
we obtain a map as in the statement of the lemma.
We may check this map is an isomorphism on cohomology sheaves
by checking it induces isomorphisms on stalks.
This follows from
Algebra, Lemma \ref{algebra-lemma-NL-localize-bottom} and
\ref{algebra-lemma-localize-NL}
and
Modules, Lemma \ref{modules-lemma-stalk-NL}
(and the description of the stalks of
$\mathcal{O}_X$ and $f^{-1}\mathcal{O}_Y$
at a point $\mathfrak p \in \Spec(A)$ as $A_\mathfrak p$ and
$R_\mathfrak q$ where $\mathfrak q = R \cap \mathfrak p$; references
used are Schemes, Lemma \ref{schemes-lemma-spec-sheaves}
and
Sheaves, Lemma \ref{sheaves-lemma-stalk-pullback}).
\end{proof}

\begin{lemma}
\label{lemma-netherlander-quasi-coherent}
Let $f : X \to Y$ be a morphism of schemes. The cohomology sheaves
of the complex $\NL_{X/Y}$ are quasi-coherent, zero outside
degrees $-1$, $0$ and equal to $\Omega_{X/Y}$ in degree $0$.
\end{lemma}

\begin{proof}
By construction of the naive cotangent complex in
Modules, Section \ref{modules-section-netherlander}
we have that $\NL_{X/Y}$ is a complex sitting in degrees $-1$, $0$
and that its cohomology in degree $0$ is $\Omega_{X/Y}$.
The sheaf of differentials is quasi-coherent (by
Morphisms, Lemma \ref{morphisms-lemma-differentials-diagonal}).
To finish the proof it suffices to show that $H^{-1}(\NL_{X/Y})$
is quasi-coherent. This follows by checking over affines
using Lemma \ref{lemma-NL-affine}.
\end{proof}

\begin{lemma}
\label{lemma-netherlander-fp}
Let $f : X \to Y$ be a morphism of schemes. If $f$ is locally of finite
presentation, then $\NL_{X/Y}$ is locally on $X$ quasi-isomorphic to
a complex
$$
\ldots \to 0 \to \mathcal{F}^{-1} \to \mathcal{F}^0 \to 0 \to \ldots
$$
of quasi-coherent $\mathcal{O}_X$-modules
with $\mathcal{F}^0$ of finite presentation
and $\mathcal{F}^{-1}$ of finite type.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-NL-affine} it suffices to show that $\NL_{A/R}$
has this shape if $R \to A$ is a finitely presented ring map.
Write $A = R[x_1, \ldots, x_n]/I$ with $I$ finitely generated.
Then $I/I^2$ is a finite
$A$-module and $\NL_{A/R}$ is quasi-isomorphic to
$$
\ldots \to 0 \to I/I^2 \to
\bigoplus\nolimits_{i = 1, \ldots, n} A\text{d}x_i \to 0 \to \ldots
$$
by Algebra, Section \ref{algebra-section-netherlander}
and in particular
Algebra, Lemma \ref{algebra-lemma-NL-homotopy}.
\end{proof}

\begin{lemma}
\label{lemma-NL-formally-smooth}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item $f$ is formally smooth,
\item $H^{-1}(\NL_{X/Y}) = 0$ and $H^0(\NL_{X/Y}) = \Omega_{X/Y}$
is locally projective.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from Algebra, Proposition
\ref{algebra-proposition-characterize-formally-smooth}
and Lemma \ref{lemma-formally-smooth}.
\end{proof}

\begin{lemma}
\label{lemma-NL-formally-etale}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item $f$ is formally \'etale,
\item $H^{-1}(\NL_{X/Y}) = H^0(\NL_{X/Y}) = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
A formally \'etale morphism is formally smooth and hence
we have $H^{-1}(\NL_{X/Y}) = 0$ by Lemma \ref{lemma-NL-formally-smooth}.
On the other hand, we have $\Omega_{X/Y} = 0$ by
Lemma \ref{lemma-characterize-formally-etale}.
Conversely, if (2) holds, then $f$ is formally smooth by
Lemma \ref{lemma-NL-formally-smooth}
and formally unramified by
Lemma \ref{lemma-formally-unramified-differentials}
and hence formally \'etale by
Lemmas \ref{lemma-formally-etale-unramified-smooth}.
\end{proof}

\begin{lemma}
\label{lemma-NL-smooth}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item $f$ is smooth, and
\item $f$ is locally of finite presentation,
$H^{-1}(\NL_{X/Y}) = 0$, and $H^0(\NL_{X/Y}) = \Omega_{X/Y}$
is finite locally free.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from the definition of a smooth ring homomorphism
(Algebra, Definition \ref{algebra-definition-smooth}),
Lemma \ref{lemma-NL-affine}, and
the definition of a smooth morphism of schemes
(Morphisms, Definition \ref{morphisms-definition-smooth}).
We also use that finite locally free is the same as
finite projective for modules over rings
(Algebra, Lemma \ref{algebra-lemma-finite-projective}).
\end{proof}

\begin{lemma}
\label{lemma-NL-etale}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item $f$ is \'etale, and
\item $f$ is locally of finite presentation and
$H^{-1}(\NL_{X/Y}) = H^0(\NL_{X/Y}) = 0$.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows from the definition of an \'etale ring homomorphism
(Algebra, Definition \ref{algebra-definition-etale}),
Lemma \ref{lemma-NL-affine}, and
the definition of an \'etale morphism of schemes
(Morphisms, Definition \ref{morphisms-definition-etale}).
\end{proof}


\begin{lemma}
\label{lemma-NL-immersion}
Let $i : Z \to X$ be an immersion of schemes. Then $\NL_{Z/X}$
is isomorphic to $\mathcal{C}_{Z/X}[1]$ in $D(\mathcal{O}_Z)$
where $\mathcal{C}_{Z/X}$ is the conormal sheaf of $Z$ in $X$.
\end{lemma}

\begin{proof}
This follows from Algebra, Lemma \ref{algebra-lemma-NL-surjection},
Morphisms, Lemma \ref{morphisms-lemma-affine-conormal}, and
Lemma \ref{lemma-NL-affine}.
\end{proof}

\begin{lemma}
\label{lemma-exact-sequence-NL}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of schemes.
There is a canonical six term exact sequence
$$
H^{-1}(f^*\NL_{Y/Z}) \to
H^{-1}(\NL_{X/Z}) \to
H^{-1}(\NL_{X/Y}) \to
f^*\Omega_{Y/Z} \to \Omega_{X/Z} \to \Omega_{X/Y} \to 0
$$
of cohomology sheaves.
\end{lemma}

\begin{proof}
Special case of
Modules, Lemma \ref{modules-lemma-exact-sequence-NL-ringed-topoi}.
\end{proof}

\begin{lemma}
\label{lemma-get-triangle-NL}
Let $f : X \to Y$ and $Y \to Z$ be morphisms of schemes. Assume
$X \to Y$ is a complete intersection morphism. Then there is
a canonical distinguished triangle
$$
f^*\NL_{Y/Z} \to \NL_{X/Z} \to \NL_{X/Y} \to f^*\NL_{Y/Z}[1]
$$
in $D(\mathcal{O}_X)$ which recovers the $6$-term exact sequence of
Lemma \ref{lemma-exact-sequence-NL}.
\end{lemma}

\begin{proof}
It suffices to show the canonical map
$$
f^*\NL_{Y/Z} \to \text{Cone}(\NL_{X/Y} \to \NL_{X/Z})[-1]
$$
of Modules, Lemma \ref{modules-lemma-exact-sequence-NL-ringed-topoi}
is an isomorphism in $D(\mathcal{O}_X)$. In order to show this, it
suffices to show that the $6$-term sequence has
a zero on the left, i.e., that $H^{-1}(f^*\NL_{Y/Z}) \to H^{-1}(\NL_{X/Z})$
is injective. Affine locally this follows from the corresponding
algebra result in More on Algebra, Lemma
\ref{more-algebra-lemma-transitive-lci-at-end}.
To translate into algebra use Lemma \ref{lemma-NL-affine}.
\end{proof}

\begin{lemma}
\label{lemma-smooth-etale-permanence}
Let $X \to Y \to Z$ be morphisms of schemes. Assume $X \to Z$ smooth
and $Y \to Z$ \'etale. Then $X \to Y$ is smooth.
\end{lemma}

\begin{proof}
The morphism $X \to Y$ is locally of finite presentation by
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}.
By Lemma \ref{lemma-NL-smooth} we have $H^{-1}(\NL_{X/Z}) = 0$
and the module $\Omega_{X/Z}$ is finite locally free.
By Lemma \ref{lemma-NL-etale} we have
$H^{-1}(\NL_{Y/Z}) = H^0(\NL_{Y/Z}) = 0$.
By Lemma \ref{lemma-exact-sequence-NL} we get
$H^{-1}(\NL_{X/Y}) = 0$ and $\Omega_{X/Y} \cong \Omega_{X/Z}$
is finite locally free.
By Lemma \ref{lemma-NL-smooth} the morphism $X \to Y$ is smooth.
\end{proof}

\begin{lemma}
\label{lemma-get-NL}
Let $f : X \to Y$ be a morphism of schemes which factors
as $f = g \circ i$ with $i$ an immersion and $g : P \to Y$
formally smooth (for example smooth). Then there is a canonical isomorphism
$$
\NL_{X/Y} \cong \left(\mathcal{C}_{X/P} \to i^*\Omega_{P/Y}\right)
$$
in $D(\mathcal{O}_X)$ where the conormal sheaf $\mathcal{C}_{X/P}$
is placed in degree $-1$.
\end{lemma}

\begin{proof}
(For the parenthetical statement see Lemma \ref{lemma-smooth-formally-smooth}.)
By Lemmas \ref{lemma-NL-immersion} and \ref{lemma-NL-formally-smooth} we have
$\NL_{X/P} = \mathcal{C}_{X/P}[1]$ and $\NL_{P/Y} = \Omega_{P/Y}$ with
$\Omega_{P/Y}$ locally projective. This implies that
$i^*\NL_{P/Y} \to i^*\Omega_{P/Y}$ is a quasi-isomorphism too
(small detail omitted; the reason is that $i^*\NL_{P/Y}$ is the
same thing as $\tau_{\geq -1}Li^*\NL_{P/Y}$, see More on Algebra, Lemma
\ref{more-algebra-lemma-tensor-NL}).
Thus the canonical map
$$
i^*\NL_{P/Y} \to \text{Cone}(\NL_{X/Y} \to \NL_{X/P})[-1]
$$
of Modules, Lemma \ref{modules-lemma-exact-sequence-NL-ringed-topoi}
is an isomorphism in $D(\mathcal{O}_X)$ because the cohomology
group $H^{-1}(i^*\NL_{P/Y})$ is zero by what we said above.
In other words, we have a distinguished triangle
$$
i^*\NL_{P/Y} \to \NL_{X/Y} \to \NL_{X/P} \to i^*\NL_{P/Y}[1]
$$
Clearly, this means that $\NL_{X/Y}$ is the cone on the map
$\NL_{X/P}[-1] \to i^*\NL_{P/Y}$ which is equivalent to the
statement of the lemma by our computation of the cohomology
sheaves of these objects in the derived category given above.
\end{proof}

\begin{lemma}
\label{lemma-base-change-NL}
Consider a cartesian diagram of schemes
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d] & X \ar[d] \\
Y' \ar[r] & Y
}
$$
The canonical map $(g')^*\NL_{X/Y} \to \NL_{X'/Y'}$ induces
an isomorphism on $H^0$ and a surjection on $H^{-1}$.
\end{lemma}

\begin{proof}
Translated into algebra this is
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-NL}.
To do the translation use Lemma \ref{lemma-NL-affine}.
\end{proof}

\begin{lemma}
\label{lemma-flat-base-change-NL}
Consider a cartesian diagram of schemes
$$
\xymatrix{
X' \ar[d] \ar[r]_{g'} & X \ar[d] \\
Y' \ar[r] & Y
}
$$
If $Y' \to Y$ is flat, then the canonical map
$(g')^*\NL_{X/Y} \to \NL_{X'/Y'}$ is a quasi-isomorphism.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-NL-affine} this follows from
Algebra, Lemma \ref{algebra-lemma-change-base-NL}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-NL-flat}
Consider a cartesian diagram of schemes
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d] & X \ar[d] \\
Y' \ar[r] & Y
}
$$
If $X \to Y$ is flat, then the canonical map
$(g')^*\NL_{X/Y} \to \NL_{X'/Y'}$ is a quasi-isomorphism.
If in addition $\NL_{X/Y}$ has tor-amplitude in $[-1, 0]$
then $L(g')^*\NL_{X/Y} \to \NL_{X'/Y'}$ is a quasi-isomorphism too.
\end{lemma}

\begin{proof}
Translated into algebra this is
More on Algebra, Lemma \ref{more-algebra-lemma-base-change-NL-flat}.
To do the translation use Lemma \ref{lemma-NL-affine}
and Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded} and
\ref{perfect-lemma-tor-dimension-affine}.
\end{proof}











\section{Pushouts in the category of schemes, I}
\label{section-pushouts}

\noindent
In this section we construct pushouts of $Y \leftarrow X \rightarrow X'$
where $X \to Y$ is affine and $X \to X'$ is a thickening. This will
actually be an important case for us, hence a detailed discussion is merited.
In Section \ref{section-pushouts-II} we discuss a more interesting
and more difficult case. See Categories, Section
\ref{categories-section-pushouts} for a general
discussion of pushouts in any category.

\begin{lemma}
\label{lemma-basic-example-pushout}
Let $A' \to A$ be a surjection of rings and let $B \to A$ be a ring map.
Let $B' = B \times_A A'$ be the fibre product of rings. Set
$S = \Spec(A)$, $S' = \Spec(A')$, $T = \Spec(B)$, and $T' = \Spec(B')$.
Then
$$
\vcenter{
\xymatrix{
S \ar[r]_i \ar[d]_f & S' \ar[d]^{f'} \\
T \ar[r]^{i'} & T'
}
}
\quad\text{corresponding to}\quad
\vcenter{
\xymatrix{
A & A' \ar[l] \\
B \ar[u] & B' \ar[l] \ar[u]
}
}
$$
is a pushout of schemes.
\end{lemma}

\begin{proof}
By More on Algebra, Lemma \ref{more-algebra-lemma-points-of-fibre-product}
we have $T' = T \amalg_S S'$ as topological spaces, i.e., the diagram
is a pushout in the category of topological spaces. Next, consider
the map
$$
((i')^\sharp, (f')^\sharp) :
\mathcal{O}_{T'}
\longrightarrow
i'_*\mathcal{O}_T \times_{g_*\mathcal{O}_S} f'_*\mathcal{O}_{S'}
$$
where $g = i' \circ f = f' \circ i$. We claim this map is an isomorphism of
sheaves of rings. Namely, we can view both sides as quasi-coherent
$\mathcal{O}_{T'}$-modules (use
Schemes, Lemmas \ref{schemes-lemma-push-forward-quasi-coherent}
for the right hand side) and the map is $\mathcal{O}_{T'}$-linear.
Thus it suffices to show the map is an isomorphism on the level
of global sections
(Schemes, Lemma \ref{schemes-lemma-equivalence-quasi-coherent}).
On global sections we recover the identification
$B' \to B \times_A A'$ from statement of the lemma (this is
how we chose $B'$).

\medskip\noindent
Let $X$ be a scheme. Suppose we are given morphisms of schemes
$m' : S' \to X$ and $n : T \to X$ such that $m' \circ i = n \circ f$
(call this $m$). We get a unique map of topological spaces
$n' : T' \to X$ compatible with $m'$ and $n$ as
$T' = T \amalg_S S'$ (see above).
By the description of $\mathcal{O}_{T'}$ in the previous
paragraph we obtain a unique homomorphism of sheaves of rings
$$
(n')^\sharp :
\mathcal{O}_X
\longrightarrow
(n')_*\mathcal{O}_{T'} =
m'_*\mathcal{O}_T \times_{m_*\mathcal{O}_T} n_*\mathcal{O}_S
$$
given by $(m')^\sharp$ and $n^\sharp$.
Thus $(n', (n')^\sharp)$ is the unque morphism of
ringed spaces $T' \to X$ compatible with $m'$ and $n$.
To finish the proof it suffices to show that $n'$
is a morphism of schemes, i.e., a morphism of locally ringed spaces.

\medskip\noindent
Let $t' \in T'$ with image $x \in X$.
We have to show that $\mathcal{O}_{X, x} \to \mathcal{O}_{T', t'}$
is local. If $t' \not \in T$, then $t'$ is the image of a unique
point $s' \in S'$ and $\mathcal{O}_{T', t'} = \mathcal{O}_{S', s'}$.
Namely, $S' \setminus S \to T' \setminus T$ is an isomorphism of
schemes as $B' \to A'$ induces an isomorphism
$\Ker(B' \to B) = \Ker(A' \to A)$.
If $t'$ is the image of $t \in T$, then
we know that the composition
$\mathcal{O}_{X, x} \to \mathcal{O}_{T', t'} \to \mathcal{O}_{T, t}$
is local and we conclude also.
\end{proof}

\begin{lemma}
\label{lemma-pushout-fpqc-local}
Let $\mathcal{I} \to (\Sch/S)_{fppf}$, $i \mapsto X_i$ be a diagram of schemes.
Let $(W, X_i \to W)$ be a cocone for the diagram in the category of schemes
(Categories, Remark \ref{categories-remark-cones-and-cocones}).
If there exists a fpqc covering $\{W_a \to W\}_{a \in A}$ of schemes such that
\begin{enumerate}
\item for all $a \in A$ we have
$W_a = \colim X_i \times_W W_a$
in the category of schemes, and
\item for all $a, b \in A$ we have
$W_a \times_W W_b = \colim X_i \times_W W_a \times_W W_b$
in the category of schemes,
\end{enumerate}
then $W = \colim X_i$ in the category of schemes.
\end{lemma}

\begin{proof}
Namely, for a scheme $T$ a morphism $W \to T$ is the same thing as
collection of morphism $W_a \to T$, $a \in A$ which agree on the
overlaps $W_a \times_W W_b$, see
Descent, Lemma \ref{descent-lemma-fpqc-universal-effective-epimorphisms}.
\end{proof}

\begin{lemma}
\label{lemma-pushout-along-thickening}
Let $X \to X'$ be a thickening of schemes and let $X \to Y$ be an affine
morphism of schemes. Then there exists a pushout
$$
\xymatrix{
X \ar[r] \ar[d]_f
&
X' \ar[d]^{f'}
\\
Y \ar[r]
&
Y'
}
$$
in the category of schemes. Moreover, $Y \subset Y'$ is a
thickening, $X = Y \times_{Y'} X'$, and
$$
\mathcal{O}_{Y'} = \mathcal{O}_Y \times_{f_*\mathcal{O}_X} f'_*\mathcal{O}_{X'}
$$
as sheaves on $|Y| = |Y'|$.
\end{lemma}

\begin{proof}
We first construct $Y'$ as a ringed space. Namely, as topological
space we take $Y' = Y$. Denote $f' : X' \to Y'$ the map of topological
spaces which equals $f$. As structure sheaf $\mathcal{O}_{Y'}$ we take
the right hand side of the equation of the lemma. To see that
$Y'$ is a scheme, we have to show that any point has an affine
neighbourhood. Since the formation of the fibre product of sheaves
commutes with restricting to opens, we may assume $Y$ is affine.
Then $X$ is affine (as $f$ is affine) and $X'$ is affine as well
(see Lemma \ref{lemma-thickening-affine-scheme}).
Say $Y \leftarrow X \rightarrow X'$ corresponds
to $B \rightarrow A \leftarrow A'$. Set $B' = B \times_A A'$; this
is the global sections of $\mathcal{O}_{Y'}$. As $A' \to A$ is surjective
with locally nilpotent kernel we see that $B' \to B$ is surjective
with locally nilpotent kernel. Hence $\Spec(B') = \Spec(B)$ (as
topological spaces). We claim that $Y' = \Spec(B')$. To see this
we will show for $g' \in B'$ with image $g \in B$ that
$\mathcal{O}_{Y'}(D(g)) = B'_{g'}$. Namely, by
More on Algebra, Lemma \ref{more-algebra-lemma-diagram-localize} we see that
$$
(B')_{g'} = B_g \times_{A_h} A'_{h'}
$$
where $h \in A$, $h' \in A'$ are the images of $g'$. Since
$B_g$, resp.\ $A_h$, resp.\ $A'_{h'}$ is equal to $\mathcal{O}_Y(D(g))$,
resp.\ $f_*\mathcal{O}_X(D(g))$, resp.\ $f'_*\mathcal{O}_{X'}(D(g))$ the
claim follows.

\medskip\noindent
It remains to show that $Y'$ is the pushout.
The discussion above shows the scheme $Y'$
has an affine open covering $Y' = \bigcup W'_i$
such that the corresponding opens
$U'_i \subset X'$, $W_i \subset Y$, and
$U_i \subset X$ are affine open.
Moreover, if $A'_i$, $B_i$, $A_i$ are the rings corresponding to
$U'_i$, $W_i$, $U_i$, then
$W'_i$ corresponds to $B_i \times_{A_i} A'_i$.
Thus we can apply Lemmas \ref{lemma-basic-example-pushout} and
\ref{lemma-pushout-fpqc-local} to conclude our construction is a pushout
in the category of schemes.
\end{proof}

\noindent
In the following lemma we use the fibre product of categories as
defined in
Categories, Example \ref{categories-example-2-fibre-product-categories}.

\begin{lemma}
\label{lemma-equivalence-categories-schemes-over-pushout}
Let $X \to X'$ be a thickening of schemes and let $X \to Y$ be an
affine morphism of schemes. Let $Y' = Y \amalg_X X'$ be the pushout
(see Lemma \ref{lemma-pushout-along-thickening}). Base change gives
a functor
$$
F : (\Sch/Y') \longrightarrow (\Sch/Y) \times_{(\Sch/Y')} (\Sch/X')
$$
given by $V' \longmapsto (V' \times_{Y'} Y, V' \times_{Y'} X', 1)$
which has a left adjoint
$$
G : (\Sch/Y) \times_{(\Sch/Y')} (\Sch/X') \longrightarrow (\Sch/Y')
$$
which sends the triple $(V, U', \varphi)$ to the pushout
$V \amalg_{(V \times_Y X)} U'$. Finally, $F \circ G$ is isomorphic to the
identity functor.
\end{lemma}

\begin{proof}
Let $(V, U', \varphi)$ be an object of the fibre product category.
Set $U = U' \times_{X'} X$. Note that $U \to U'$ is a thickening.
Since $\varphi : V \times_Y X \to U' \times_{X'} X = U$ is an isomorphism
we have a morphism $U \to V$ over $X \to Y$ which identifies $U$ with
the fibre product $X \times_Y V$. In particular $U \to V$ is affine, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-affine}.
Hence we can apply Lemma \ref{lemma-pushout-along-thickening}
to get a pushout $V' = V \amalg_U U'$. Denote $V' \to Y'$ the morphism
we obtain in virtue of the fact that $V'$ is a pushout and because
we are given morphisms $V \to Y$ and $U' \to X'$ agreeing on $U$
as morphisms into $Y'$. Setting $G(V, U', \varphi) = V'$
gives the functor $G$.

\medskip\noindent
Let us prove that $G$ is a left adjoint to $F$. Let $Z$ be a scheme
over $Y'$. We have to show that
$$
\Mor(V', Z) = \Mor((V, U', \varphi), F(Z))
$$
where the morphism sets are taking in their respective categories.
Let $g' : V' \to Z$ be a morphism. Denote $\tilde g$, resp.\ $\tilde f'$
the composition of $g'$ with the morphism $V \to V'$, resp.\ $U' \to V'$.
Base change $\tilde g$, resp.\ $\tilde f'$ by $Y \to Y'$, resp.\ $X' \to Y'$
to get a morphism $g : V \to Z \times_{Y'} Y$,
resp.\ $f' : U' \to Z \times_{Y'} X'$. Then $(g, f')$ is an element
of the right hand side of the equation above (details omitted).
Conversely, suppose that $(g, f') : (V, U', \varphi) \to F(Z)$ is an
element of the right hand side.
We may consider the composition $\tilde g : V \to Z$,
resp.\ $\tilde f' : U' \to Z$ of $g$, resp.\ $f$ by
$Z \times_{Y'} X' \to Z$, resp.\ $Z \times_{Y'} Y \to Z$.
Then $\tilde g$ and $\tilde f'$ agree as morphism from $U$ to $Z$.
By the universal property of pushout, we obtain a morphism
$g' : V' \to Z$, i.e., an element of the left hand side.
We omit the verification that these constructions are mutually inverse.

\medskip\noindent
To prove that $F \circ G$ is isomorphic to the identity we have to
show that the adjunction mapping
$(V, U', \varphi) \to F(G(V, U', \varphi))$ is an isomorphism.
To do this we may work affine locally. Say $X = \Spec(A)$, $X' = \Spec(A')$,
and $Y = \Spec(B)$. Then $A' \to A$ and $B \to A$ are ring maps as in
More on Algebra, Lemma \ref{more-algebra-lemma-module-over-fibre-product}
and $Y' = \Spec(B')$ with $B' = B \times_A A'$. Next, suppose that
$V = \Spec(D)$, $U' = \Spec(C')$ and $\varphi$ is given by an
$A$-algebra isomorphism $D \otimes_B A \to C' \otimes_{A'} A = C'/IC'$.
Set $D' = D \times_{C'/IC'} C'$. In this case the statement we have to
prove is that $D' \otimes_{B'} B \cong D$ and $D' \otimes_{B'} A' \cong C'$.
This is a special case of More on Algebra, Lemma
\ref{more-algebra-lemma-module-over-fibre-product}.
\end{proof}

\begin{lemma}
\label{lemma-scheme-over-pushout-flat-modules}
Let $X \to X'$ be a thickening of schemes and let $X \to Y$ be an
affine morphism of schemes. Let $Y' = Y \amalg_X X'$ be the pushout
(see Lemma \ref{lemma-pushout-along-thickening}). Let $V' \to Y'$
be a morphism of schemes. Set
$V = Y \times_{Y'} V'$, $U' = X' \times_{Y'} V'$, and $U = X \times_{Y'} V'$.
There is an equivalence of categories between
\begin{enumerate}
\item quasi-coherent $\mathcal{O}_{V'}$-modules flat over $Y'$, and
\item the category of triples $(\mathcal{G}, \mathcal{F}', \varphi)$ where
\begin{enumerate}
\item $\mathcal{G}$ is a quasi-coherent $\mathcal{O}_V$-module flat over $Y$,
\item $\mathcal{F}'$ is a quasi-coherent $\mathcal{O}_{U'}$-module flat
over $X'$, and
\item $\varphi : (U \to V)^*\mathcal{G} \to (U \to U')^*\mathcal{F}'$
is an isomorphism of $\mathcal{O}_U$-modules.
\end{enumerate}
\end{enumerate}
The equivalence maps $\mathcal{G}'$ to
$((V \to V')^*\mathcal{G}', (U' \to V')^*\mathcal{G}', can)$.
Suppose $\mathcal{G}'$ corresponds to the triple
$(\mathcal{G}, \mathcal{F}', \varphi)$. Then
\begin{enumerate}
\item[(a)] $\mathcal{G}'$ is a finite type $\mathcal{O}_{V'}$-module if and
only if $\mathcal{G}$ and $\mathcal{F}'$ are finite type
$\mathcal{O}_Y$ and $\mathcal{O}_{U'}$-modules.
\item[(b)] if $V' \to Y'$ is locally of finite presentation, then
$\mathcal{G}'$ is an $\mathcal{O}_{V'}$-module of finite
presentation if and only if $\mathcal{G}$ and $\mathcal{F}'$ are
$\mathcal{O}_Y$ and $\mathcal{O}_{U'}$-modules of finite presentation.
\end{enumerate}
\end{lemma}

\begin{proof}
A quasi-inverse functor assigns to the triple
$(\mathcal{G}, \mathcal{F}', \varphi)$ the fibre product
$$
(V \to V')_*\mathcal{G}
\times_{(U \to V')_*\mathcal{F}}
(U' \to V')_*\mathcal{F}'
$$
where $\mathcal{F} = (U \to U')^*\mathcal{F}'$. This works, because on
affines we recover the equivalence of More on Algebra, Lemma
\ref{more-algebra-lemma-relative-flat-module-over-fibre-product}.
Some details omitted.

\medskip\noindent
Parts (a) and (b) follow from
More on Algebra, Lemmas
\ref{more-algebra-lemma-relative-finite-module-over-fibre-product} and
\ref{more-algebra-lemma-relative-finitely-presented-module-over-fibre-product}.
\end{proof}

\begin{lemma}
\label{lemma-equivalence-categories-schemes-over-pushout-flat}
In the situation of
Lemma \ref{lemma-equivalence-categories-schemes-over-pushout}.
If $V' = G(V, U', \varphi)$ for some triple $(V, U', \varphi)$, then
\begin{enumerate}
\item $V' \to Y'$ is locally of finite type if and only if $V \to Y$ and
$U' \to X'$ are locally of finite type,
\item $V' \to Y'$ is flat if and only if $V \to Y$ and $U' \to X'$ are flat,
\item $V' \to Y'$ is flat and locally of finite presentation if and only if
$V \to Y$ and $U' \to X'$ are flat and locally of finite presentation,
\item $V' \to Y'$ is smooth if and only if $V \to Y$ and $U' \to X'$ are smooth,
\item $V' \to Y'$ is \'etale if and only if $V \to Y$ and $U' \to X'$
are \'etale, and
\item add more here as needed.
\end{enumerate}
If $W'$ is flat over $Y'$, then the adjunction mapping
$G(F(W')) \to W'$ is an isomorphism. Hence $F$ and $G$ define mutually
quasi-inverse functors between the category of schemes flat over $Y'$
and the category of triples $(V, U', \varphi)$ with $V \to Y$
and $U' \to X'$ flat.
\end{lemma}

\begin{proof}
Looking over affine pieces the assertions of this lemma
are equivalent to the corresponding assertions of
More on Algebra, Lemma
\ref{more-algebra-lemma-properties-algebras-over-fibre-product}.
\end{proof}







\section{Openness of the flat locus}
\label{section-open-flat}

\noindent
This result takes some work to prove, and (perhaps)
deserves its own section. Here it is.

\begin{theorem}
\label{theorem-openness-flatness}
\begin{reference}
\cite[IV Theorem 11.3.1]{EGA}
\end{reference}
Let $S$ be a scheme.
Let $f : X \to S$ be a morphism which is locally of finite presentation.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module which is
locally of finite presentation. Then
$$
U = \{x \in X \mid \mathcal{F}\text{ is flat over }S\text{ at }x\}
$$
is open in $X$.
\end{theorem}

\begin{proof}
We may test for openness locally on $X$ hence we may assume
that $f$ is a morphism of affine schemes. In this case the
theorem is exactly
Algebra, Theorem \ref{algebra-theorem-openness-flatness}.
\end{proof}

\begin{lemma}
\label{lemma-flat-locus-base-change}
Let $S$ be a scheme.
Let
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
S' \ar[r]^g & S
}
$$
be a cartesian diagram of schemes.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Let $x' \in X'$ with images
$x = g'(x')$ and $s' = g'(x')$.
\begin{enumerate}
\item If $\mathcal{F}$ is flat over $S$ at $x$, then
$(g')^*\mathcal{F}$ is flat over $S'$ at $x'$.
\item If $g$ is flat at $s'$ and $(g')^*\mathcal{F}$ is flat over $S'$ at
$x'$, then $\mathcal{F}$ is flat over $S$ at $x$.
\end{enumerate}
In particular, if $g$ is flat, $f$ is locally of finite presentation,
and $\mathcal{F}$ is locally of finite presentation,
then formation of the open subset of
Theorem \ref{theorem-openness-flatness}
commutes with base change.
\end{lemma}

\begin{proof}
Consider the commutative diagram of local rings
$$
\xymatrix{
\mathcal{O}_{X', x'} & \mathcal{O}_{X, x} \ar[l] \\
\mathcal{O}_{S', s'} \ar[u] & \mathcal{O}_{S, s} \ar[l] \ar[u]
}
$$
Note that $\mathcal{O}_{X', x'}$
is a localization of
$\mathcal{O}_{X, x} \otimes_{\mathcal{O}_{S, s}} \mathcal{O}_{S', s'}$,
and that $((g')^*\mathcal{F})_{x'}$ is equal to
$\mathcal{F}_x \otimes_{\mathcal{O}_{X, x}} \mathcal{O}_{X', x'}$.
Hence the lemma follows from
Algebra, Lemma \ref{algebra-lemma-base-change-flat-up-down}.
\end{proof}






\section{Crit\`ere de platitude par fibres}
\label{section-criterion-flat-fibres}

\noindent
Consider a commutative diagram of schemes (left hand diagram)
$$
\xymatrix{
X \ar[rr]_f \ar[dr] & & Y \ar[dl] \\
& S
}
\quad
\xymatrix{
X_s \ar[rr]_{f_s} \ar[rd] & & Y_s \ar[dl] \\
& \Spec(\kappa(s))
}
$$
and a quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$.
Given a point $x \in X$ lying over $s \in S$ with image $y = f(x)$
we consider the question: Is $\mathcal{F}$ flat
over $Y$ at $x$? If $\mathcal{F}$ is flat over $S$ at $x$, then
the theorem states this question is intimately related to the
question of whether the restriction of $\mathcal{F}$ to the fibre
$$
\mathcal{F}_s = (X_s \to X)^*\mathcal{F}
$$
is flat over $Y_s$ at $x$. Below you will find a ``Noetherian'' version,
a ``finitely presented'' version, and earlier we treated a ``nilpotent''
version, see
Lemma \ref{lemma-flatness-morphism-thickenings}.

\begin{theorem}
\label{theorem-criterion-flatness-fibre-Noetherian}
Let $S$ be a scheme.
Let $f : X \to Y$ be a morphism of schemes over $S$.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Let $x \in X$. Set $y = f(x)$ and $s \in S$ the image of $x$ in $S$.
Assume $S$, $X$, $Y$ locally Noetherian,
$\mathcal{F}$ coherent, and $\mathcal{F}_x \not = 0$.
Then the following are equivalent:
\begin{enumerate}
\item $\mathcal{F}$ is flat over $S$ at $x$, and
$\mathcal{F}_s$ is flat over $Y_s$ at $x$, and
\item $Y$ is flat over $S$ at $y$ and $\mathcal{F}$ is
flat over $Y$ at $x$.
\end{enumerate}
\end{theorem}

\begin{proof}
Consider the ring maps
$$
\mathcal{O}_{S, s} \longrightarrow
\mathcal{O}_{Y, y} \longrightarrow \mathcal{O}_{X, x}
$$
and the module $\mathcal{F}_x$. The stalk of $\mathcal{F}_s$ at $x$
is the module $\mathcal{F}_x/\mathfrak m_s \mathcal{F}_x$ and
the local ring of $Y_s$ at $y$ is
$\mathcal{O}_{Y, y}/\mathfrak m_s \mathcal{O}_{Y, y}$.
Thus the implication (1) $\Rightarrow$ (2) is
Algebra, Lemma \ref{algebra-lemma-criterion-flatness-fibre-Noetherian}.
If (2) holds, then the first ring map is faithfully flat
and $\mathcal{F}_x$ is flat over $\mathcal{O}_{Y, y}$ so by
Algebra, Lemma \ref{algebra-lemma-composition-flat}
we see that $\mathcal{F}_x$ is flat over $\mathcal{O}_{S, s}$.
Moreover, $\mathcal{F}_x/\mathfrak m_s \mathcal{F}_x$ is the
base change of the flat module $\mathcal{F}_x$ by
$\mathcal{O}_{Y, y} \to \mathcal{O}_{Y, y}/\mathfrak m_s \mathcal{O}_{Y, y}$,
hence flat by
Algebra, Lemma \ref{algebra-lemma-flat-base-change}.
\end{proof}

\noindent
Here is the non-Noetherian version.

\begin{theorem}
\label{theorem-criterion-flatness-fibre}
Let $S$ be a scheme.
Let $f : X \to Y$ be a morphism of schemes over $S$.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Assume
\begin{enumerate}
\item $X$ is locally of finite presentation over $S$,
\item $\mathcal{F}$ an $\mathcal{O}_X$-module of finite presentation, and
\item $Y$ is locally of finite type over $S$.
\end{enumerate}
Let $x \in X$. Set $y = f(x)$ and let $s \in S$ be the image of $x$ in $S$.
If $\mathcal{F}_x \not = 0$, then the following are equivalent:
\begin{enumerate}
\item $\mathcal{F}$ is flat over $S$ at $x$, and
$\mathcal{F}_s$ is flat over $Y_s$ at $x$, and
\item $Y$ is flat over $S$ at $y$ and $\mathcal{F}$ is
flat over $Y$ at $x$.
\end{enumerate}
Moreover, the set of points $x$ where (1) and (2) hold is open in
$\text{Supp}(\mathcal{F})$.
\end{theorem}

\begin{proof}
Consider the ring maps
$$
\mathcal{O}_{S, s} \longrightarrow
\mathcal{O}_{Y, y} \longrightarrow \mathcal{O}_{X, x}
$$
and the module $\mathcal{F}_x$. The stalk of $\mathcal{F}_s$ at $x$
is the module $\mathcal{F}_x/\mathfrak m_s \mathcal{F}_x$ and
the local ring of $Y_s$ at $y$ is
$\mathcal{O}_{Y, y}/\mathfrak m_s \mathcal{O}_{Y, y}$.
Thus the implication (1) $\Rightarrow$ (2) is
Algebra, Lemma \ref{algebra-lemma-criterion-flatness-fibre-fp-over-ft}.
If (2) holds, then the first ring map is faithfully flat
and $\mathcal{F}_x$ is flat over $\mathcal{O}_{Y, y}$ so by
Algebra, Lemma \ref{algebra-lemma-composition-flat}
we see that $\mathcal{F}_x$ is flat over $\mathcal{O}_{S, s}$.
Moreover, $\mathcal{F}_x/\mathfrak m_s \mathcal{F}_x$ is the
base change of the flat module $\mathcal{F}_x$ by
$\mathcal{O}_{Y, y} \to \mathcal{O}_{Y, y}/\mathfrak m_s \mathcal{O}_{Y, y}$,
hence flat by
Algebra, Lemma \ref{algebra-lemma-flat-base-change}.

\medskip\noindent
By
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
the morphism $f$ is locally of finite presentation.
Consider the set
\begin{equation}
\label{equation-open}
U = \{x \in X \mid \mathcal{F} \text{ flat at }x
\text{ over both }Y\text{ and }S\}.
\end{equation}
This set is open in $X$ by
Theorem \ref{theorem-openness-flatness}.
Note that if $x \in U$, then $\mathcal{F}_s$ is flat at
$x$ over $Y_s$ as a base change of a flat module under the
morphism $Y_s \to Y$, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-module-flat}.
Hence at every point of $U \cap \text{Supp}(\mathcal{F})$
condition (1) is satisfied. On the other hand, it is
clear that if $x \in \text{Supp}(\mathcal{F})$ satisfies
(1) and (2), then $x \in U$. Thus the open set we are
looking for is $U \cap \text{Supp}(\mathcal{F})$.
\end{proof}

\noindent
These theorems are often used in the following simplified forms.
We give only the global statements -- of course there are also pointwise
versions.

\begin{lemma}
\label{lemma-morphism-between-flat-Noetherian}
Let $S$ be a scheme.
Let $f : X \to Y$ be a morphism of schemes over $S$.
Assume
\begin{enumerate}
\item $S$, $X$, $Y$ are locally Noetherian,
\item $X$ is flat over $S$,
\item for every $s \in S$ the morphism
$f_s : X_s \to Y_s$ is flat.
\end{enumerate}
Then $f$ is flat. If $f$ is also surjective, then $Y$ is flat over $S$.
\end{lemma}

\begin{proof}
This is a special case of
Theorem \ref{theorem-criterion-flatness-fibre-Noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-morphism-between-flat}
Let $S$ be a scheme.
Let $f : X \to Y$ be a morphism of schemes over $S$.
Assume
\begin{enumerate}
\item $X$ is locally of finite presentation over $S$,
\item $X$ is flat over $S$,
\item for every $s \in S$ the morphism
$f_s : X_s \to Y_s$ is flat, and
\item $Y$ is locally of finite type over $S$.
\end{enumerate}
Then $f$ is flat. If $f$ is also surjective, then $Y$ is flat over $S$.
\end{lemma}

\begin{proof}
This is a special case of
Theorem \ref{theorem-criterion-flatness-fibre}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-criterion-flatness-fibre}
Let $S$ be a scheme. Let $f : X \to Y$ be a morphism of schemes over $S$.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Assume
\begin{enumerate}
\item $X$ is locally of finite presentation over $S$,
\item $\mathcal{F}$ an $\mathcal{O}_X$-module of finite presentation,
\item $\mathcal{F}$ is flat over $S$, and
\item $Y$ is locally of finite type over $S$.
\end{enumerate}
Then the set
$$
U = \{x \in X \mid \mathcal{F} \text{ flat at }x \text{ over }Y\}.
$$
is open in $X$ and its formation commutes with arbitrary base change:
If $S' \to S$ is a morphism of schemes, and $U'$ is the set of points
of $X' = X \times_S S'$ where $\mathcal{F}' = \mathcal{F} \times_S S'$
is flat over $Y' = Y \times_S S'$, then $U' = U \times_S S'$.
\end{lemma}

\begin{proof}
By
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}
the morphism $f$ is locally of finite presentation.
Hence $U$ is open by
Theorem \ref{theorem-openness-flatness}.
Because we have assumed that $\mathcal{F}$ is flat over $S$ we see that
Theorem \ref{theorem-criterion-flatness-fibre}
implies
$$
U = \{x \in X \mid \mathcal{F}_s \text{ flat at }x \text{ over }Y_s\}.
$$
where $s$ always denotes the image of $x$ in $S$. (This description also
works trivially when $\mathcal{F}_x = 0$.) Moreover, the assumptions
of the lemma remain in force for the morphism $f' : X' \to Y'$
and the sheaf $\mathcal{F}'$. Hence $U'$ has a similar description.
In other words, it suffices to prove that given
$s' \in S'$ mapping to $s \in S$ we have
$$
\{x' \in X'_{s'} \mid
\mathcal{F}'_{s'} \text{ flat at }x' \text{ over }Y'_{s'}\}
$$
is the inverse image of the corresponding locus in $X_s$.
This is true by
Lemma \ref{lemma-flat-locus-base-change}
because in the cartesian diagram
$$
\xymatrix{
X'_{s'} \ar[d] \ar[r] & X_s \ar[d] \\
Y'_{s'} \ar[r] & Y_s
}
$$
the horizontal morphisms are flat as they are base changes by the flat
morphism $\Spec(\kappa(s')) \to \Spec(\kappa(s))$.
\end{proof}

\begin{lemma}
\label{lemma-base-change-flatness-fibres}
Let $S$ be a scheme. Let $f : X \to Y$ be a morphism of schemes over $S$.
Assume
\begin{enumerate}
\item $X$ is locally of finite presentation over $S$,
\item $X$ is flat over $S$, and
\item $Y$ is locally of finite type over $S$.
\end{enumerate}
Then the set
$$
U = \{x \in X \mid X\text{ flat at }x \text{ over }Y\}.
$$
is open in $X$ and its formation commutes with arbitrary base change.
\end{lemma}

\begin{proof}
This is a special case of
Lemma \ref{lemma-base-change-criterion-flatness-fibre}.
\end{proof}

\noindent
The following lemma is a variant of
Algebra, Lemma \ref{algebra-lemma-free-fibre-flat-free}.
Note that the hypothesis
that $(\mathcal{F}_s)_x$ is a flat $\mathcal{O}_{X_s, x}$-module
means that $(\mathcal{F}_s)_x$ is a free $\mathcal{O}_{X_s, x}$-module
which is always the case if $x \in X_s$ is a generic point of an
irreducible component of $X_s$ and $X_s$ is reduced (namely, in
this case $\mathcal{O}_{X_s, x}$ is a field, see
Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}).

\begin{lemma}
\label{lemma-flat-and-free-at-point-fibre}
Let $f : X \to S$ be a morphism of schemes of finite presentation.
Let $\mathcal{F}$ be a finitely presented $\mathcal{O}_X$-module.
Let $x \in X$ with image $s \in S$.
If $\mathcal{F}$ is flat at $x$ over $S$ and $(\mathcal{F}_s)_x$ is a flat
$\mathcal{O}_{X_s, x}$-module, then $\mathcal{F}$
is finite free in a neighbourhood of $x$.
\end{lemma}

\begin{proof}
If $\mathcal{F}_x \otimes \kappa(x)$ is zero, then $\mathcal{F}_x = 0$
by Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK}) and hence
$\mathcal{F}$ is zero in a neighbourhood of $x$
(Modules, Lemma \ref{modules-lemma-finite-type-stalk-zero})
and the lemma holds. Thus we may assume $\mathcal{F}_x \otimes \kappa(x)$
is not zero and we see that
Theorem \ref{theorem-criterion-flatness-fibre}
applies with $f = \text{id} : X \to X$. We conclude that $\mathcal{F}_x$
is flat over $\mathcal{O}_{X, x}$. Hence $\mathcal{F}_x$ is free, see
Algebra, Lemma \ref{algebra-lemma-finite-flat-local} for example.
Choose an open neighbourhood $x \in U \subset X$ and sections
$s_1, \ldots, s_r \in \mathcal{F}(U)$ which map to a basis in
$\mathcal{F}_x$. The corresponding map
$\psi : \mathcal{O}_U^{\oplus r} \to \mathcal{F}|_U$ is surjective after
shrinking $U$ (Modules, Lemma \ref{modules-lemma-finite-type-stalk-zero}).
Then $\Ker(\psi)$ is of finite type (see Modules, Lemma
\ref{modules-lemma-kernel-surjection-finite-free-onto-finite-presentation})
and $\Ker(\psi)_x = 0$. Whence after shrinking $U$ once more
$\psi$ is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-finite-free-open}
Let $f : X \to S$ be a morphism of schemes which is
locally of finite presentation.
Let $\mathcal{F}$ be a finitely presented $\mathcal{O}_X$-module
flat over $S$. Then the set
$$
\{x \in X : \mathcal{F}\text{ free in a neighbourhood of }x\}
$$
is open in $X$ and its formation commutes with arbitrary base change
$S' \to S$.
\end{lemma}

\begin{proof}
Openness holds trivially. Let $x \in X$ mapping to $s \in S$.
By Lemma \ref{lemma-flat-and-free-at-point-fibre}
we see that $x$ is in our set if and only if
$\mathcal{F}|_{X_s}$ is flat at $x$ over $X_s$.
Clearly this is also equivalent to $\mathcal{F}$ being
flat at $x$ over $X$ (because this statement is
implied by freeness of $\mathcal{F}_x$ and implies
flatness of $\mathcal{F}|_{X_s}$ at $x$ over $X_s$).
Thus the base change statement follows from
Lemma \ref{lemma-base-change-criterion-flatness-fibre}
applied to $\text{id} : X \to X$ over $S$.
\end{proof}








\section{Flat modules and relative assassins}
\label{section-flat-relative-assassin}

\noindent
In this section we will prove that the support of a flat module is
(in some sense) equidimensional over the base in geometric situations.
For the Noetherian case we refer the reader to
\cite[IV Proposition 12.1.1.5]{EGA}.
First, we prove two helper lemmas.

\begin{lemma}
\label{lemma-mod-injective-valuation-ring}
Let $A$ be a valuation ring. Let $A \to B$ is a local homomorphism of
local rings which is essentially of finite type.
Let $u : N \to M$ be a map of finite $B$-modules.
Assume $M$ is flat over $A$ and
$\overline{u} : N/\mathfrak m_A N \to M/\mathfrak m_A M$ is injective.
Then $u$ is injective and $M/u(N)$ is flat over $A$.
\end{lemma}

\begin{proof}
We will deduce this lemma from
Algebra, Lemma \ref{algebra-lemma-mod-injective-general}
(please note that we exchanged the roles of $M$ and $N$).
To do the reduction we will use More on Algebra, Lemma
\ref{more-algebra-lemma-valuation-ring-flat-essentially-finite-type}
to reduce to the finitely presented case.

\medskip\noindent
By assumption we can write $B$ as a quotient of the localization of
a polynomial algebra $P = A[x_1, \ldots, x_n]$ at a prime ideal
$\mathfrak q$. Then we can think of $u : N \to M$ as a map
of finite $P_\mathfrak q$-modules. Hence we may and do assume that
$B$ is essentially of finite presentation over $A$.

\medskip\noindent
Next, the $B$-module $N$ is finite but perhaps not of finite presentation.
Write $N = \colim N_\lambda$ as a filtered colimit of finitely presented
$B$-modules with surjective transition maps. For example choose
a presentation $0 \to K \to B^{\oplus r} \to N \to 0$,
write $K$ as the union of its finite submodules $K_\lambda$, and
set $N_\lambda = \Coker(K_\lambda \to B^{\oplus r})$.
The module $N/\mathfrak m_A N$ is of finite presentation
over the Noetherian ring $B/\mathfrak m_A B$.
Hence for $\lambda$ large enough we have
$N_\lambda/\mathfrak m_A N_\lambda = N/\mathfrak m_A N$.
Now, if we can show the lemma for the composition
$u_\lambda : N_\lambda \to M$, then we conclude that
$N_\lambda = N$ and the result holds for $u$.
Hence we may and do assume $N$ is of finite presentation over $B$.

\medskip\noindent
By More on Algebra, Lemma
\ref{more-algebra-lemma-valuation-ring-flat-essentially-finite-type}
the module $M$ is of finite presentation over $B$.
Thus all the assumptions of
Algebra, Lemma \ref{algebra-lemma-mod-injective-general}
hold and we conclude.
\end{proof}

\begin{lemma}
\label{lemma-make-base-change}
\begin{reference}
This can be found in the proof of
\cite[IV Proposition 12.1.1.5]{EGA}
\end{reference}
Let $f : X \to S$ be a morphism of schemes. Let $y \in X$ be a point
with image $t \in S$. Denote $Y \subset X$ the closure of $\{y\}$
viewed as an integral closed subscheme of $X$. Let $s \in S$ and let
$x \in Y_s$ be a generic point of an irreducible component of $Y_s$.
There exists a cartesian diagram
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]_{f'} & X \ar[d]^f \\
S' \ar[r]^g & S
}
$$
with the following properties:
\begin{enumerate}
\item $S'$ is the spectrum of a valuation ring
with generic point $t'$ and closed point $s'$,
\item $g(t') = t$ and $g(s') = s$,
\item there exists a point $y' \in X'_{t'}$ which is
a generic point of an irreducible component of
$(S' \times_S Y)_{t'} = Y_t \times_t t'$
and satisfies $g'(y') = y$,
\item denoting $Y' \subset X'$ the closure of $\{y'\}$
viewed as an integral closed subscheme of $X'$
there exists a point $x' \in Y'_{s'}$ which is a generic
point of an irreducible component of $Y'_{s'}$
with $g'(x') = x$.
\end{enumerate}
\end{lemma}

\begin{proof}
We choose a valuation ring $R$, we set $S' = \Spec(R)$ with
generic point $t'$ and closed point $s'$, and we choose a morphism
$h : S' \to X$ with $h(t') = y$ and $h(s') = x$.
See Schemes, Lemma \ref{schemes-lemma-points-specialize}.
Set $g = f \circ h$ so that $g(t') = t$ and $g(s') = s$.
Consider the base change
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d] & X \ar[d] \\
S' \ar@/^1em/[u]^\sigma \ar[r]^-g & S
}
$$
We obtain a section $\sigma$ of the base change such that
$h = g' \circ \sigma$.

\medskip\noindent
Of course $\sigma$ factors through the base change $S' \times_S Y$ of $Y$
as $h$ factors through $Y$. Let $y' \in X'_{t'} \subset X'$ be the
generic point of an irreducible component of the fibre
$$
(S' \times_S Y)_{t'} = Y_t \times_t t'
$$
containing the point $\sigma(t')$, i.e., such that
$y' \leadsto \sigma(t')$.
Since $g'(y') \in Y_t$ and $g(y') \leadsto g(\sigma(t')) = y$
we find that $g'(y') = y$ because $y$ is the generic point of
the fibre $Y_t$.
Denote $Y' \subset X'$ the closure of $\{y'\}$ in $X'$ viewed
as an integral closed subscheme.
Then $\sigma$ factors through $Y'$ as $\sigma(t') \in Y'$.
Choose a generic point $x' \in Y'_{s'}$ of an irreducible
component of $Y'_{s'}$ which contains $\sigma(s')$, i.e., we
get $x' \leadsto \sigma(s')$ and hence $g'(x') \leadsto g'(\sigma(s')) = x$.
Again as $x$ is a generic point of an irreducible component of $Y_s$
by assumption
and as $g'(Y') \subset Y$ we conclude that $g'(x') = x$.
\end{proof}

\begin{lemma}
\label{lemma-associated-point-specializes}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}$ be a quasi-coherent finite type $\mathcal{O}_X$-module.
Let $y \in \text{Ass}_{X/S}(\mathcal{F})$ with image $t \in S$.
Denote $Y \subset X$ the closure of $\{y\}$ in $X$ viewed
as an integral closed subscheme. Let $s \in S$
and let $x \in Y_s$ be a generic point of an irreducible component
of $Y_s$. If $\mathcal{F}$ is flat over $S$ at $x$, then
$x \in \text{Ass}_{X/S}(\mathcal{F})$ and
$\dim_x(Y_s) = \dim(Y_t)$.
\end{lemma}

\begin{proof}
Choose a diagram as in Lemma \ref{lemma-make-base-change}.
Set $\mathcal{F}' = (g')^*\mathcal{F}$.
Divisors, Lemma \ref{divisors-lemma-base-change-relative-assassin}
implies that $y' \in \text{Ass}_{X'/S'}(\mathcal{F}')$.
By our choice of $y'$ we also see that $\dim(Y'_{t'}) = \dim(Y_t)$,
see for example Algebra, Lemma
\ref{algebra-lemma-inequalities-under-field-extension}.
By Algebra, Lemma
\ref{algebra-lemma-finite-type-domain-over-valuation-ring-dim-fibres}
we see that $Y'_{s'}$ is equidimensional of dimension equal to $\dim(Y_t)$.
Since $\mathcal{F}$ is flat at $x$ over $S$ we see that
$\mathcal{F}'$ is flat at $x'$ over $S'$, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-module-flat}.

\medskip\noindent
Suppose that we can show $x' \in \text{Ass}_{X'/S}(\mathcal{F}')$. Then
Divisors, Lemma \ref{divisors-lemma-base-change-relative-assassin}
implies that $x \in \text{Ass}_{X/S}(\mathcal{F})$ and that
the irreducible component $C'$ of $Y'_{s'}$ containing $x'$
is an irreducible component of $C \times_s s'$ where $C \subset Y_s$
is the irreducible component containing $x$.
Whence $\dim(C) = \dim(C') = \dim(Y_t)$ (see above) and the
proof is complete.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $S = \Spec(A)$ where $A$ is a valuation ring
and $t$ and $s$ are the generic and closed points of $S$.
We will assume $x \not \in \text{Ass}_{X/S}(\mathcal{F})$
in order to get a contradiction. In other words, we assume
$x \not \in \text{Ass}_{X_s}(\mathcal{F}_s)$ where
$\mathcal{F}_s$ is the pullback of $\mathcal{F}$ to $X_s$.
Consider the ring map
$$
A \longrightarrow \mathcal{O}_{X, x} = B
$$
and the module $N = \mathcal{F}_x$ over $B = \mathcal{O}_{X, x}$.
Then $B/\mathfrak m_A B = \mathcal{O}_{X_s, x}$ and
$N/\mathfrak m_A N$ is the stalk of $\mathcal{F}_s$ at the point $x$.
Denote $\mathfrak q \subset B$ the prime ideal corresponding to the
point $y$, see Schemes, Lemma \ref{schemes-lemma-specialize-points}.
Since $x$ is a generic point of $Y_s$ we see that the radical of
$\mathfrak q + \mathfrak m_A B$ is $\mathfrak m_B$.
Then $\text{Ass}_{B/\mathfrak m_A B}(N/\mathfrak m_A N)$
is a finite set of prime ideals (Algebra, Lemma \ref{algebra-lemma-finite-ass})
which doesn't contain the maximal ideal of $B/\mathfrak m_A B$
since $x \not \in \text{Ass}_{X/S}(\mathcal{F})$.
Thus the image of of $\mathfrak q$ in $B/\mathfrak m_A B$ is not
contained in any of those prime ideals. Hence
by prime avoidance (Algebra, Lemma \ref{algebra-lemma-silly})
we can find an element $g \in \mathfrak q$
whose image in $B/\mathfrak m_A B$ is a nonzerodivisor on
$N/\mathfrak m_A N$ (this uses the description of zerodivisors
in Algebra, Lemma \ref{algebra-lemma-ass-zero-divisors}). Since
$N = \mathcal{F}_x$ is $A$-flat by
Lemma \ref{lemma-mod-injective-valuation-ring} we see that
$$
g : N \longrightarrow N
$$
is injective. In particular, if $K = \text{Frac}(A)$ is the
fraction field of $A$, then we see that
$$
g : N \otimes_A K \longrightarrow N \otimes_A K
$$
is injective. Observe that $\mathfrak q$ corresponds to a
prime ideal of $B \otimes_A K$. Denote $\mathcal{F}_t$ the
restriction of $\mathcal{F}$ to the generic fibre $X_t$. We have
$(B \otimes_A K)_{\mathfrak q} = \mathcal{O}_{X_t, y}$
and $(N \otimes_A K)_\mathfrak q$
is the stalk at $y$ of $\mathcal{F}_t$. Hence we find
that $g \in \mathfrak m_y \subset \mathcal{O}_{X_t, y}$
is a nonzerodivisor on the stalk $(\mathcal{F}_t)_y$
which contradicts our assumption that $y \in \text{Ass}_{X/S}(\mathcal{F})$.
\end{proof}

\begin{lemma}
\label{lemma-flat-associated-equidimensional}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module of finite type.
Let $y \in \text{Ass}_{X/S}(\mathcal{F})$.
Denote $Y \subset X$ the closure of $\{y\}$ in $X$ viewed
as an integral closed subscheme. Denote $T \subset S$ the closure
of $\{f(y)\}$ viewed as an integral closed subscheme. We obtain
a commutative diagram
$$
\xymatrix{
Y \ar[r] \ar[d] & X \ar[d] \\
T \ar[r] & S
}
$$
where $Y \to T$ is dominant. Assume $\mathcal{F}$ is flat over $S$
at all generic points of irreducible components of fibres of $Y \to T$
(for example if $\mathcal{F}$ is flat over $S$). Then
\begin{enumerate}
\item if $s \in S$ and $x \in Y_s$ is the generic point of an
irreducible component of $Y_s$, then $x \in \text{Ass}_{X/S}(\mathcal{F})$, and
\item there is an integer $d \geq 0$ such that
$Y \to T$ is of relative dimension $d$, see
Morphisms, Definition \ref{morphisms-definition-relative-dimension-d}.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows immediately from the pointwise version
Lemma \ref{lemma-associated-point-specializes}.
Note that to compute the dimension of the locally
algebraic schemes $Y_s$ it suffices to look near
the generic points, see Varieties, Section
\ref{varieties-section-algebraic-schemes}.
\end{proof}

\begin{remark}
\label{remark-flat-equidimensional}
Here are some cases where the material above, especially
Lemma \ref{lemma-flat-associated-equidimensional},
allows one to conclude that a morphism $f : X \to S$ of schemes
has relative dimension $d$ as defined in
Morphisms, Definition \ref{morphisms-definition-relative-dimension-d}.
For example, this is true if
\begin{enumerate}
\item $X$ is integral with generic point $\xi$,
\item the transcendence degree of $\kappa(\xi)$ over $\kappa(f(\xi))$ is $d$,
\item $f$ is locally of finite type, and
\item there exists a quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$
of finite type which is flat over $S$ with $\text{Supp}(\mathcal{F}) = X$.
\end{enumerate}
Another set of hypotheses that work are the following:
\begin{enumerate}
\item $S$ is irreducible with generic point $\eta$,
\item $X_\eta$ is dense in $X$,
\item every irreducible component of $X_\eta$ has dimension $d$,
\item $f$ is locally of finite type, and
\item there exists a quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$
of finite type which is flat over $S$ with $\text{Supp}(\mathcal{F}) = X$.
\end{enumerate}
Of course, we can relax the flatness condition on $\mathcal{F}$
and require only that $\mathcal{F}$ is flat over $S$ in codimension $0$,
i.e., that $\mathcal{F}$ is flat over $S$ at every generic point of
every fibre. If we ever need these results, we will carefully state and
prove them here.
\end{remark}











\section{Normalization revisited}
\label{section-normalization}

\noindent
Normalization commutes with smooth base change.

\begin{lemma}
\label{lemma-integral-closure-smooth-pullback}
Let $f : Y \to X$ be a smooth morphism of schemes. Let $\mathcal{A}$ be a
quasi-coherent sheaf of $\mathcal{O}_X$-algebras. The integral closure
of $\mathcal{O}_Y$ in $f^*\mathcal{A}$ is equal to $f^*\mathcal{A}'$
where $\mathcal{A}' \subset \mathcal{A}$ is the integral closure of
$\mathcal{O}_X$ in $\mathcal{A}$.
\end{lemma}

\begin{proof}
This is a translation of
Algebra, Lemma \ref{algebra-lemma-integral-closure-commutes-smooth}
into the language of schemes. Details omitted.
\end{proof}

\begin{lemma}[Normalization commutes with smooth base change]
\label{lemma-normalization-smooth-localization}
Let
$$
\xymatrix{
Y_2 \ar[r] \ar[d]_{f_2} & Y_1 \ar[d]^{f_1} \\
X_2 \ar[r]^\varphi & X_1
}
$$
be a fibre square in the category of schemes. Assume $f_1$ is quasi-compact
and quasi-separated, and $\varphi$ is smooth.
Let $Y_i \to X_i' \to X_i$ be the normalization of $X_i$ in $Y_i$.
Then $X_2' \cong X_2 \times_{X_1} X_1'$.
\end{lemma}

\begin{proof}
The base change of the factorization $Y_1 \to X_1' \to X_1$ to $X_2$
is a factorization $Y_2 \to X_2 \times_{X_1} X_1' \to X_2$ and
$X_2 \times_{X_1} X_1' \to X_2$ is integral
(Morphisms, Lemma \ref{morphisms-lemma-base-change-finite}).
Hence we get a morphism
$h : X_2' \to X_2 \times_{X_1} X_1'$ by the universal property of
Morphisms, Lemma \ref{morphisms-lemma-characterize-normalization}.
Observe that $X_2'$ is the relative spectrum of the integral closure
of $\mathcal{O}_{X_2}$ in $f_{2, *}\mathcal{O}_{Y_2}$.
If $\mathcal{A}' \subset f_{1, *}\mathcal{O}_{Y_1}$ denotes the integral
closure of $\mathcal{O}_{X_2}$, then $X_2 \times_{X_1} X_1'$ is the
relative spectrum of $\varphi^*\mathcal{A}'$, see
Constructions, Lemma \ref{constructions-lemma-spec-properties}.
By
Cohomology of Schemes, Lemma \ref{coherent-lemma-flat-base-change-cohomology}
we know that $f_{2, *}\mathcal{O}_{Y_2} = \varphi^*f_{1, *}\mathcal{O}_{Y_1}$.
Hence the result follows from
Lemma \ref{lemma-integral-closure-smooth-pullback}.
\end{proof}

\begin{lemma}[Normalization and smooth morphisms]
\label{lemma-normalization-and-smooth}
Let $X \to Y$ be a smooth morphism of schemes. Assume every quasi-compact
open of $Y$ has finitely many irreducible components. Then the same
is true for $X$ and there is a unique isomorphism $X^\nu = X \times_Y Y^\nu$
over $X$ where $X^\nu$, $Y^\nu$ are the normalizations of $X$, $Y$.
\end{lemma}

\begin{proof}
By Descent, Lemma \ref{descent-lemma-locally-finite-nr-irred-local-fppf}
every quasi-compact open of $X$ has finitely many irreducible components.
Note that $X_{red} = X \times_Y Y_{red}$ as a scheme smooth over a reduced
scheme is reduced, see
Descent, Lemma \ref{descent-lemma-reduced-local-smooth}.
Hence we may assume that $X$ and $Y$ are reduced (as the normalization
of a scheme is equal to the normalization of its reduction by
definition). Next, note that $X' = X \times_Y Y^\nu$ is a normal scheme
by Descent, Lemma \ref{descent-lemma-normal-local-smooth}.
The morphism $X' \to Y^\nu$ is smooth (hence flat) thus the generic
points of irreducible components of $X'$ lie over generic points of
irreducible components of $Y^\nu$. Since $Y^\nu \to Y$ is birational
we conclude that $X' \to X$ is birational too (because $X' \to Y^\nu$
induces an isomorphism on fibres over generic points of $Y$).
We conclude that there exists a factorization
$X^\nu \to X' \to X$, see
Morphisms, Lemma \ref{morphisms-lemma-normalization-normal}
which is an isomorphism as $X'$ is normal and integral over $X$.
\end{proof}

\begin{lemma}[Normalization and henselization]
\label{lemma-normalization-and-henselization}
Let $X$ be a locally Noetherian scheme. Let $\nu : X^\nu \to X$
be the normalization morphism. Then for any point $x \in X$
the base change
$$
X^\nu \times_X \Spec(\mathcal{O}_{X, x}^h) \to \Spec(\mathcal{O}_{X, x}^h),
\quad\text{resp.}\quad
X^\nu \times_X \Spec(\mathcal{O}_{X, x}^{sh}) \to \Spec(\mathcal{O}_{X, x}^{sh})
$$
is the normalization of $\Spec(\mathcal{O}_{X, x}^h)$,
resp.\ $\Spec(\mathcal{O}_{X, x}^{sh})$.
\end{lemma}

\begin{proof}
Let $\eta_1, \ldots, \eta_r$ be the generic points of the irreducible
components of $X$ passing through $x$. The base change of the normalization to
$\Spec(\mathcal{O}_{X, x})$ is the spectrum of the
integral closure of $\mathcal{O}_{X, x}$ in $\prod \kappa(\eta_i)$.
This follows from our construction of the normalization of $X$ in
Morphisms, Definition \ref{morphisms-definition-normalization}
and Morphisms, Lemma \ref{morphisms-lemma-integral-closure};
you can also use the description of the normalization
in Morphisms, Lemma \ref{morphisms-lemma-description-normalization}.
Thus we reduce to the following algebra problem.
Let $A$ be a Noetherian local ring; recall that this implies
the henselization $A^h$ and strict henselization $A^{sh}$
are Noetherian too (More on Algebra, Lemma
\ref{more-algebra-lemma-henselization-noetherian}).
Let $\mathfrak p_1, \ldots, \mathfrak p_r$
be its minimal primes. Let $A'$ be the integral closure
of $A$ in $\prod \kappa(\mathfrak p_i)$.
Problem: show that
$A' \otimes_A A^h$, resp.\ $A' \otimes_A A^{sh}$ is constructed
from the Noetherian local ring $A^h$, resp.\ $A^{sh}$ in the same
manner.

\medskip\noindent
Since $A^h$, resp.\ $A^{sh}$ are colimits of \'etale $A$-algebras,
we see that the minimal primes of $A$ and $A^{sh}$ are exactly
the primes of $A^h$, resp.\ $A^{sh}$ lying over the minimal primes
of $A$ (by going down, see
Algebra, Lemmas \ref{algebra-lemma-flat-going-down} and
\ref{algebra-lemma-minimal-prime-image-minimal-prime}).
Thus More on Algebra, Lemma \ref{more-algebra-lemma-fibres-henselization}
tells us that
$A^h \otimes_A \prod \kappa(\mathfrak p_i)$,
resp.
$A^{sh} \otimes_A \prod \kappa(\mathfrak p_i)$
is the product of the residue fields at the minimal primes
of $A^h$, resp.\ $A^{sh}$. We know that taking the
integral closure in an overring commutes with \'etale
base change, see
Algebra, Lemma \ref{algebra-lemma-integral-closure-commutes-etale}.
Writing $A^h$ and $A^{sh}$ as a limit of \'etale $A$-algebras
we see that the same thing is true for the base change to
$A^h$ and $A^{sh}$ (you can also use the more general
Algebra, Lemma \ref{algebra-lemma-integral-closure-commutes-colim-smooth}).
\end{proof}








\section{Normal morphisms}
\label{section-normal}

\noindent
In the article \cite{DM} of Deligne and Mumford the notion of a normal
morphism is mentioned. This is just one in a series of types\footnote{
The other types are coprof $\leq k$, Cohen-Macaulay, $(S_k)$,
regular, $(R_k)$, and reduced. See \cite[IV Definition 6.8.1.]{EGA}.
Gorenstein morphisms will be defined in
Duality for Schemes, Section \ref{duality-section-gorenstein}.}
of morphisms that can all be defined similarly. Over time we will add
these in their own sections as needed.

\begin{definition}
\label{definition-normal}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
\begin{enumerate}
\item Let $x \in X$, and $y = f(x)$. We say that $f$ is {\it normal at $x$}
if $f$ is flat at $x$, and the scheme $X_y$ is geometrically
normal at $x$ over $\kappa(y)$ (see
Varieties, Definition \ref{varieties-definition-geometrically-normal}).
\item We say $f$ is a {\it normal morphism} if $f$ is normal
at every point of $X$.
\end{enumerate}
\end{definition}

\noindent
So the condition that the morphism $X \to Y$ is normal
is stronger than just requiring all
the fibres to be normal locally Noetherian schemes.

\begin{lemma}
\label{lemma-normal}
Let $f : X \to Y$ be a morphism of schemes.
Assume all fibres of $f$ are locally Noetherian.
The following are equivalent
\begin{enumerate}
\item $f$ is normal, and
\item $f$ is flat and its fibres are geometrically normal schemes.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows directly from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-smooth-normal}
A smooth morphism is normal.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ be a smooth morphism.
As $f$ is locally of finite presentation, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-locally-finite-presentation}
the fibres $X_y$ are locally of finite type over a field, hence
locally Noetherian. Moreover, $f$ is flat, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat}.
Finally, the fibres $X_y$ are smooth over a field (by
Morphisms, Lemma \ref{morphisms-lemma-base-change-smooth})
and hence geometrically normal by
Varieties, Lemma \ref{varieties-lemma-smooth-geometrically-normal}.
Thus $f$ is normal by
Lemma \ref{lemma-normal}.
\end{proof}

\noindent
We want to show that this notion is local on the source and target
for the smooth topology. First we deal with the property of having
locally Noetherian fibres.

\begin{lemma}
\label{lemma-locally-Noetherian-fibres-fppf-local-source-and-target}
The property $\mathcal{P}(f)=$``the fibres of $f$ are locally Noetherian''
is local in the fppf topology on the source and the target.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ be a morphism of schemes.
Let $\{\varphi_i : Y_i \to Y\}_{i \in I}$ be an fppf covering of $Y$.
Denote $f_i : X_i \to Y_i$ the base change of $f$ by $\varphi_i$.
Let $i \in I$ and let $y_i \in Y_i$ be a point.
Set $y = \varphi_i(y_i)$. Note that
$$
X_{i, y_i} = \Spec(\kappa(y_i)) \times_{\Spec(\kappa(y))} X_y.
$$
Moreover, as $\varphi_i$ is of finite presentation the field extension
$\kappa(y_i)/\kappa(y)$ is finitely generated.
Hence in this situation we have that $X_y$ is locally Noetherian if and
only if $X_{i, y_i}$ is locally Noetherian, see
Varieties, Lemma \ref{varieties-lemma-locally-Noetherian-base-change}.
This fact implies locality on the target.

\medskip\noindent
Let $\{X_i \to X\}$ be an fppf covering of $X$.
Let $y \in Y$. In this case $\{X_{i, y} \to X_y\}$ is an
fppf covering of the fibre. Hence the locality on the source
follows from Descent, Lemma \ref{descent-lemma-Noetherian-local-fppf}.
\end{proof}

\begin{lemma}
\label{lemma-normal-fppf-local-source-and-target}
The property
$\mathcal{P}(f)=$``the fibres of $f$ are locally Noetherian and $f$ is normal''
is local in the fppf topology on the target and
local in the smooth topology on the source.
\end{lemma}

\begin{proof}
We have
$\mathcal{P}(f) =
\mathcal{P}_1(f) \wedge \mathcal{P}_2(f) \wedge \mathcal{P}_3(f)$
where
$\mathcal{P}_1(f)=$``the fibres of $f$ are locally Noetherian'',
$\mathcal{P}_2(f)=$``$f$ is flat'', and
$\mathcal{P}_3(f)=$``the fibres of $f$ are geometrically normal''.
We have already seen that $\mathcal{P}_1$ and $\mathcal{P}_2$
are local in the fppf topology on the source and the target, see
Lemma \ref{lemma-locally-Noetherian-fibres-fppf-local-source-and-target},
and Descent, Lemmas \ref{descent-lemma-descending-property-flat} and
\ref{descent-lemma-flat-fpqc-local-source}. Thus we have to deal
with $\mathcal{P}_3$.

\medskip\noindent
Let $f : X \to Y$ be a morphism of schemes.
Let $\{\varphi_i : Y_i \to Y\}_{i \in I}$ be an fpqc covering of $Y$.
Denote $f_i : X_i \to Y_i$ the base change of $f$ by $\varphi_i$.
Let $i \in I$ and let $y_i \in Y_i$ be a point.
Set $y = \varphi_i(y_i)$. Note that
$$
X_{i, y_i} = \Spec(\kappa(y_i)) \times_{\Spec(\kappa(y))} X_y.
$$
Hence in this situation we have that $X_y$ is geometrically normal if and
only if $X_{i, y_i}$ is geometrically normal, see
Varieties, Lemma \ref{varieties-lemma-geometrically-normal-upstairs}.
This fact implies $\mathcal{P}_3$ is fpqc local on the target.

\medskip\noindent
Let $\{X_i \to X\}$ be a smooth covering of $X$.
Let $y \in Y$. In this case $\{X_{i, y} \to X_y\}$ is a
smooth covering of the fibre. Hence the locality of $\mathcal{P}_3$
for the smooth topology on the source follows from
Descent, Lemma \ref{descent-lemma-normal-local-smooth}.
Combining the above the lemma follows.
\end{proof}



\section{Regular morphisms}
\label{section-regular}

\noindent
Compare with Section \ref{section-normal}. The algebraic version of
this notion is discussed in
More on Algebra, Section \ref{more-algebra-section-regular}.

\begin{definition}
\label{definition-regular}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
\begin{enumerate}
\item Let $x \in X$, and $y = f(x)$. We say that $f$ is {\it regular at $x$}
if $f$ is flat at $x$, and the scheme $X_y$ is geometrically
regular at $x$ over $\kappa(y)$ (see
Varieties, Definition \ref{varieties-definition-geometrically-regular}).
\item We say $f$ is a {\it regular morphism} if $f$ is regular
at every point of $X$.
\end{enumerate}
\end{definition}

\noindent
The condition that the morphism $X \to Y$ is regular
is stronger than just requiring all
the fibres to be regular locally Noetherian schemes.

\begin{lemma}
\label{lemma-regular}
Let $f : X \to Y$ be a morphism of schemes.
Assume all fibres of $f$ are locally Noetherian.
The following are equivalent
\begin{enumerate}
\item $f$ is regular,
\item $f$ is flat and its fibres are geometrically regular schemes,
\item for every pair of affine opens $U \subset X$, $V \subset Y$
with $f(U) \subset V$ the ring map $\mathcal{O}(V) \to \mathcal{O}(U)$
is regular,
\item there exists an open covering $Y = \bigcup_{j \in J} V_j$
and open coverings $f^{-1}(V_j) = \bigcup_{i \in I_j} U_i$ such
that each of the morphisms $U_i \to V_j$ is regular, and
\item there exists an affine open covering $Y = \bigcup_{j \in J} V_j$
and affine open coverings $f^{-1}(V_j) = \bigcup_{i \in I_j} U_i$ such
that the ring maps $\mathcal{O}(V_j) \to \mathcal{O}(U_i)$ are regular.
\end{enumerate}
\end{lemma}

\begin{proof}
The equivalence of (1) and (2) is immediate from the definitions.
Let $x \in X$ with $y = f(x)$. By definition $f$ is flat at $x$
if and only if $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$ is a
flat ring map, and $X_y$ is geometrically regular at $x$ over
$\kappa(y)$ if and only if
$\mathcal{O}_{X_y, x} = \mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is a geometrically regular algebra over $\kappa(y)$. Hence
Whether or not $f$ is regular at $x$
depends only on the local homomorphism of local rings
$\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$.
Thus the equivalence of (1) and (4) is clear.

\medskip\noindent
Recall (More on Algebra, Definition \ref{more-algebra-definition-regular})
that a ring map $A \to B$ is regular if and only if it is flat
and the fibre rings $B \otimes_A \kappa(\mathfrak p)$ are Noetherian
and geometrically regular for all primes $\mathfrak p \subset A$.
By Varieties, Lemma \ref{varieties-lemma-geometrically-regular}
this is equivalent to $\Spec(B \otimes_A \kappa(\mathfrak p))$
being a geometrically regular scheme over $\kappa(\mathfrak p)$.
Thus we see that (2) implies (3). It is clear that (3) implies
(5). Finally, assume (5). This implies that $f$ is flat
(see Morphisms, Lemma \ref{morphisms-lemma-flat-characterize}).
Moreover, if $y \in Y$, then $y \in V_j$ for some $j$ and we see
that $X_y = \bigcup_{i \in I_j} U_{i, y}$ with each $U_{i, y}$
geometrically regular over $\kappa(y)$ by
Varieties, Lemma \ref{varieties-lemma-geometrically-regular}.
Another application of
Varieties, Lemma \ref{varieties-lemma-geometrically-regular}
shows that $X_y$ is geometrically regular. Hence (2) holds
and the proof of the lemma is finished.
\end{proof}

\begin{lemma}
\label{lemma-smooth-regular}
A smooth morphism is regular.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ be a smooth morphism.
As $f$ is locally of finite presentation, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-locally-finite-presentation}
the fibres $X_y$ are locally of finite type over a field, hence
locally Noetherian. Moreover, $f$ is flat, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat}.
Finally, the fibres $X_y$ are smooth over a field (by
Morphisms, Lemma \ref{morphisms-lemma-base-change-smooth})
and hence geometrically regular by
Varieties, Lemma \ref{varieties-lemma-smooth-geometrically-normal}.
Thus $f$ is regular by
Lemma \ref{lemma-regular}.
\end{proof}

\begin{lemma}
\label{lemma-regular-fppf-local-source-and-target}
The property $\mathcal{P}(f)=$``the fibres of $f$ are
locally Noetherian and $f$ is regular''
is local in the fppf topology on the target and
local in the smooth topology on the source.
\end{lemma}

\begin{proof}
We have
$\mathcal{P}(f) =
\mathcal{P}_1(f) \wedge \mathcal{P}_2(f) \wedge \mathcal{P}_3(f)$
where
$\mathcal{P}_1(f)=$``the fibres of $f$ are locally Noetherian'',
$\mathcal{P}_2(f)=$``$f$ is flat'', and
$\mathcal{P}_3(f)=$``the fibres of $f$ are geometrically regular''.
We have already seen that $\mathcal{P}_1$ and $\mathcal{P}_2$
are local in the fppf topology on the source and the target, see
Lemma \ref{lemma-locally-Noetherian-fibres-fppf-local-source-and-target},
and Descent, Lemmas \ref{descent-lemma-descending-property-flat} and
\ref{descent-lemma-flat-fpqc-local-source}. Thus we have to deal
with $\mathcal{P}_3$.

\medskip\noindent
Let $f : X \to Y$ be a morphism of schemes.
Let $\{\varphi_i : Y_i \to Y\}_{i \in I}$ be an fpqc covering of $Y$.
Denote $f_i : X_i \to Y_i$ the base change of $f$ by $\varphi_i$.
Let $i \in I$ and let $y_i \in Y_i$ be a point.
Set $y = \varphi_i(y_i)$. Note that
$$
X_{i, y_i} = \Spec(\kappa(y_i)) \times_{\Spec(\kappa(y))} X_y.
$$
Hence in this situation we have that $X_y$ is geometrically regular if and
only if $X_{i, y_i}$ is geometrically regular, see
Varieties, Lemma \ref{varieties-lemma-geometrically-regular-upstairs}.
This fact implies $\mathcal{P}_3$ is fpqc local on the target.

\medskip\noindent
Let $\{X_i \to X\}$ be a smooth covering of $X$.
Let $y \in Y$. In this case $\{X_{i, y} \to X_y\}$ is a
smooth covering of the fibre. Hence the locality of $\mathcal{P}_3$
for the smooth topology on the source follows from
Descent, Lemma \ref{descent-lemma-regular-local-smooth}.
Combining the above the lemma follows.
\end{proof}




\section{Cohen-Macaulay morphisms}
\label{section-CM}

\noindent
Compare with Section \ref{section-normal}.
Note that, as pointed out in
Algebra, Section \ref{algebra-section-geometrically-CM}
and
Varieties, Section \ref{varieties-section-CM}
``geometrically Cohen-Macaulay'' is the same as plain Cohen-Macaulay.

\begin{definition}
\label{definition-CM}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
\begin{enumerate}
\item Let $x \in X$, and $y = f(x)$. We say that $f$ is
{\it Cohen-Macaulay at $x$} if $f$ is flat at $x$, and the
local ring of the scheme $X_y$ at $x$ is Cohen-Macaulay.
\item We say $f$ is a {\it Cohen-Macaulay morphism} if $f$ is
Cohen-Macaulay at every point of $X$.
\end{enumerate}
\end{definition}

\noindent
Here is a translation.

\begin{lemma}
\label{lemma-CM}
Let $f : X \to Y$ be a morphism of schemes.
Assume all fibres of $f$ are locally Noetherian.
The following are equivalent
\begin{enumerate}
\item $f$ is Cohen-Macaulay, and
\item $f$ is flat and its fibres are Cohen-Macaulay schemes.
\end{enumerate}
\end{lemma}

\begin{proof}
This follows directly from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-CM-dimension}
Let $f : X \to Y$ be a morphism of locally Noetherian schemes
which is locally of finite type and Cohen-Macaulay.
For every point $x$ in $X$ with image $y$ in $Y$,
$$
\dim_x(X) = \dim_y(Y) + \dim_x(X_y),
$$
where $X_y$ denotes the fiber over $y$.
\end{lemma}

\begin{proof}
After replacing $X$ by an open neighborhood of $x$,
there is a natural number $d$ such that all fibers
of $X \to Y$ have dimension $d$ at every point, see
Morphisms, Lemma
\ref{morphisms-lemma-flat-finite-presentation-CM-fibres-relative-dimension}.
Then $f$ is flat, locally of finite type
and of relative dimension $d$. Hence the result follows from
Morphisms, Lemma \ref{morphisms-lemma-rel-dimension-dimension}.
\end{proof}

\begin{lemma}
\label{lemma-composition-CM}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of schemes. Assume that the
fibres of $f$, $g$, and $g \circ f$ are locally Noetherian.
Let $x \in X$ with images $y \in Y$ and $z \in Z$.
\begin{enumerate}
\item If $f$ is Cohen-Macaulay at $x$ and $g$ is Cohen-Macaulay
at $f(x)$, then $g \circ f$ is Cohen-Macaulay at $x$.
\item If $f$ and $g$ are Cohen-Macaulay, then $g \circ f$ is Cohen-Macaulay.
\item If $g \circ f$ is Cohen-Macaulay at $x$ and $f$ is flat at $x$,
then $f$ is Cohen-Macaulay at $x$ and $g$ is Cohen-Macaulay at $f(x)$.
\item If $g \circ f$ is Cohen-Macaulay and $f$ is flat, then
$f$ is Cohen-Macaulay and $g$ is Cohen-Macaulay at every point in
the image of $f$.
\end{enumerate}
\end{lemma}

\begin{proof}
Consider the map of Noetherian local rings
$$
\mathcal{O}_{Y_z, y} \to \mathcal{O}_{X_z, x}
$$
and observe that its fibre is
$$
\mathcal{O}_{X_z, x}/\mathfrak m_{Y_z, y}\mathcal{O}_{X_z, x} =
\mathcal{O}_{X_y, x}
$$
Thus the lemma this follows from
Algebra, Lemma \ref{algebra-lemma-CM-goes-up}.
\end{proof}

\begin{lemma}
\label{lemma-flat-morphism-from-CM-scheme}
Let $f : X \to Y$ be a flat morphism of locally Noetherian schemes.
If $X$ is Cohen-Macaulay, then $f$ is Cohen-Macaulay and
$\mathcal{O}_{Y, f(x)}$ is Cohen-Macaulay for all $x \in X$.
\end{lemma}

\begin{proof}
After translating into algebra this follows from
Algebra, Lemma \ref{algebra-lemma-CM-goes-up}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-CM}
Let $f : X \to Y$ be a morphism of schemes.
Assume that all the fibres $X_y$ are locally Noetherian schemes.
Let $Y' \to Y$ be locally of finite type. Let $f' : X' \to Y'$
be the base change of $f$.
Let $x' \in X'$ be a point with image $x \in X$.
\begin{enumerate}
\item If $f$ is Cohen-Macaulay at $x$, then
$f' : X' \to Y'$ is Cohen-Macaulay at $x'$.
\item If $f$ is flat at $x$ and $f'$ is Cohen-Macaulay at $x'$, then $f$
is Cohen-Macaulay at $x$.
\item If $Y' \to Y$ is flat at $f'(x')$ and $f'$ is Cohen-Macaulay at
$x'$, then $f$ is Cohen-Macaulay at $x$.
\end{enumerate}
\end{lemma}

\begin{proof}
Note that the assumption on $Y' \to Y$ implies that for $y' \in Y'$
mapping to $y \in Y$ the field extension $\kappa(y')/\kappa(y)$
is finitely generated. Hence also all the fibres
$X'_{y'} = (X_y)_{\kappa(y')}$ are locally Noetherian, see
Varieties, Lemma \ref{varieties-lemma-locally-Noetherian-base-change}.
Thus the lemma makes sense. Set $y' = f'(x')$ and $y = f(x)$.
Hence we get the following commutative diagram of local rings
$$
\xymatrix{
\mathcal{O}_{X', x'} & \mathcal{O}_{X, x} \ar[l] \\
\mathcal{O}_{Y', y'} \ar[u] & \mathcal{O}_{Y, y} \ar[l] \ar[u]
}
$$
where the upper left corner is a localization of the tensor product
of the upper right and lower left corners over the lower right corner.

\medskip\noindent
Assume $f$ is Cohen-Macaulay at $x$.
The flatness of $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$
implies the flatness of $\mathcal{O}_{Y', y'} \to \mathcal{O}_{X', x'}$, see
Algebra, Lemma \ref{algebra-lemma-base-change-flat-up-down}.
The fact that $\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Cohen-Macaulay implies that
$\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Cohen-Macaulay, see
Varieties, Lemma \ref{varieties-lemma-CM-base-change}. Hence we see that $f'$
is Cohen-Macaulay at $x'$.

\medskip\noindent
Assume $f$ is flat at $x$ and $f'$ is Cohen-Macaulay at $x'$.
The fact that $\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Cohen-Macaulay implies that
$\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Cohen-Macaulay, see
Varieties, Lemma \ref{varieties-lemma-CM-base-change}.
Hence we see that $f$ is Cohen-Macaulay at $x$.

\medskip\noindent
Assume $Y' \to Y$ is flat at $y'$ and $f'$ is Cohen-Macaulay at
$x'$. The flatness of $\mathcal{O}_{Y', y'} \to \mathcal{O}_{X', x'}$
and $\mathcal{O}_{Y, y} \to \mathcal{O}_{Y', y'}$ implies the flatness
of $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$, see
Algebra, Lemma \ref{algebra-lemma-base-change-flat-up-down}.
The fact that $\mathcal{O}_{X', x'}/\mathfrak m_{y'}\mathcal{O}_{X', x'}$
is Cohen-Macaulay implies that
$\mathcal{O}_{X, x}/\mathfrak m_y\mathcal{O}_{X, x}$
is Cohen-Macaulay, see
Varieties, Lemma \ref{varieties-lemma-CM-base-change}. Hence we see that $f$
is Cohen-Macaulay at $x$.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-CM-open}
\begin{reference}
\cite[IV Corollary 12.1.7(iii)]{EGA}
\end{reference}
Let $f : X \to S$ be a morphism of schemes which is flat and locally
of finite presentation. Let
$$
W = \{x \in X \mid f\text{ is Cohen-Macaulay at }x\}
$$
Then
\begin{enumerate}
\item $W = \{x \in X \mid \mathcal{O}_{X_{f(x)}, x}\text{ is Cohen-Macaulay}\}$,
\item $W$ is open in $X$,
\item $W$ dense in every fibre of $X \to S$,
\item the formation of $W$ commutes with arbitrary base change of $f$:
For any morphism $g : S' \to S$, consider
the base change $f' : X' \to S'$ of $f$ and the
projection $g' : X' \to X$. Then the corresponding
set $W'$ for the morphism $f'$ is equal to $W' = (g')^{-1}(W)$.
\end{enumerate}
\end{lemma}

\begin{proof}
As $f$ is flat with locally Noetherian fibres the equality in (1) holds
by definition. Parts (2) and (3) follow from
Algebra, Lemma \ref{algebra-lemma-generic-CM-flat-finite-presentation}.
Part (4) follows either from
Algebra, Lemma \ref{algebra-lemma-CM-locus-commutes-base-change}
or
Varieties, Lemma \ref{varieties-lemma-CM-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-characterize-CM}
Let $f : X \to S$ be a morphism of schemes which is flat and locally
of finite presentation. Let $x \in X$ with image $s \in S$.
Set $d = \dim_x(X_s)$.
The following are equivalent
\begin{enumerate}
\item $f$ is Cohen-Macaulay at $x$,
\item there exists an open neighbourhood $U \subset X$ of $x$
and a locally quasi-finite morphism $U \to \mathbf{A}^d_S$ over $S$
which is flat at $x$,
\item there exists an open neighbourhood $U \subset X$ of $x$
and a locally quasi-finite flat morphism $U \to \mathbf{A}^d_S$ over $S$,
\item for any $S$-morphism $g : U \to \mathbf{A}^d_S$
of an open neighbourhood $U \subset X$ of $x$ we have:
$g$ is quasi-finite at $x$ $\Rightarrow$ $g$ is flat at $x$.
\end{enumerate}
\end{lemma}

\begin{proof}
Openness of flatness shows (2) and (3)
are equivalent, see Theorem \ref{theorem-openness-flatness}.

\medskip\noindent
Choose affine open $U = \Spec(A) \subset X$ with $x \in U$ and
$V = \Spec(R) \subset S$ with $f(U) \subset V$. Then $R \to A$
is a flat ring map of finite presentation. Let $\mathfrak p \subset A$
be the prime ideal corresponding to $x$. After replacing $A$ by a
principal localization we may assume there exists a quasi-finite map
$R[x_1, \ldots, x_d]  \to A$, see
Algebra, Lemma \ref{algebra-lemma-quasi-finite-over-polynomial-algebra}.
Thus there exists at least one pair $(U, g)$ consisting of an
open neighbourhood $U \subset X$ of $x$ and a locally\footnote{If $S$
is quasi-separated, then $g$ will be quasi-finite.} quasi-finite morphism
$g : U \to \mathbf{A}^d_S$.

\medskip\noindent
Claim: Given $R \to A$ flat and of finite presentation, a prime
$\mathfrak p \subset A$ and $\varphi : R[x_1, \ldots, x_d] \to A$
quasi-finite at $\mathfrak p$ we have: $\Spec(\varphi)$
is flat at $\mathfrak p$ if and only if $\Spec(A) \to \Spec(R)$
is Cohen-Macaulay at $\mathfrak p$.  Namely, by
Theorem \ref{theorem-criterion-flatness-fibre}
flatness may be checked on fibres. The same is true
for being Cohen-Macaulay (as $A$ is already assumed flat over $R$).
Thus the claim follows from
Algebra, Lemma \ref{algebra-lemma-where-CM}.

\medskip\noindent
The claim shows that (1) is equivalent to (4) and combined with the
fact that we have constructed a suitable $(U, g)$ in the second
paragraph, the claim also shows that (1) is equivalent to (2).
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-CM-pieces}
Let $f : X \to S$ be a morphism of schemes which is flat and locally
of finite presentation. For $d \geq 0$ there exist opens $U_d \subset X$
with the following properties
\begin{enumerate}
\item $W = \bigcup_{d \geq 0} U_d$ is dense in every fibre of $f$, and
\item $U_d \to S$ is of relative dimension $d$ (see
Morphisms, Definition \ref{morphisms-definition-relative-dimension-d}).
\end{enumerate}
\end{lemma}

\begin{proof}
This follows by combining
Lemma \ref{lemma-flat-finite-presentation-CM-open}
with
Morphisms, Lemma
\ref{morphisms-lemma-flat-finite-presentation-CM-fibres-relative-dimension}.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-specialization-dimension}
Let $f : X \to S$ be a morphism of schemes which is flat and locally
of finite presentation.
Suppose $x' \leadsto x$ is a specialization of points of $X$
with image $s' \leadsto s$ in $S$. If $x$ is a generic point of an
irreducible component of $X_s$ then $\dim_{x'}(X_{s'}) = \dim_x(X_s)$.
\end{lemma}

\begin{proof}
The point $x$ is contained in $U_d$ for some $d$, where $U_d$ as in
Lemma \ref{lemma-flat-finite-presentation-CM-pieces}.
\end{proof}

\begin{lemma}
\label{lemma-CM-local-source-and-target}
The property
$\mathcal{P}(f)=$``the fibres of $f$ are locally Noetherian and $f$ is
Cohen-Macaulay'' is local in the fppf topology on the target and
local in the syntomic topology on the source.
\end{lemma}

\begin{proof}
We have
$\mathcal{P}(f) =
\mathcal{P}_1(f) \wedge \mathcal{P}_2(f)$
where
$\mathcal{P}_1(f)=$``$f$ is flat'', and
$\mathcal{P}_2(f)=$``the fibres of $f$ are locally Noetherian
and Cohen-Macaulay''.
We know that $\mathcal{P}_1$ is
local in the fppf topology on the source and the target, see
Descent, Lemmas \ref{descent-lemma-descending-property-flat} and
\ref{descent-lemma-flat-fpqc-local-source}. Thus we have to deal
with $\mathcal{P}_2$.

\medskip\noindent
Let $f : X \to Y$ be a morphism of schemes.
Let $\{\varphi_i : Y_i \to Y\}_{i \in I}$ be an fppf covering of $Y$.
Denote $f_i : X_i \to Y_i$ the base change of $f$ by $\varphi_i$.
Let $i \in I$ and let $y_i \in Y_i$ be a point.
Set $y = \varphi_i(y_i)$. Note that
$$
X_{i, y_i} = \Spec(\kappa(y_i)) \times_{\Spec(\kappa(y))} X_y.
$$
and that $\kappa(y_i)/\kappa(y)$ is a finitely generated field
extension. Hence if $X_y$ is locally Noetherian, then
$X_{i, y_i}$ is locally Noetherian, see
Varieties, Lemma \ref{varieties-lemma-locally-Noetherian-base-change}.
And if in addition $X_y$ is Cohen-Macaulay,
then $X_{i, y_i}$ is Cohen-Macaulay, see
Varieties, Lemma \ref{varieties-lemma-CM-base-change}.
Thus $\mathcal{P}_2$ is fppf local on the target.

\medskip\noindent
Let $\{X_i \to X\}$ be a syntomic covering of $X$.
Let $y \in Y$. In this case $\{X_{i, y} \to X_y\}$ is a
syntomic covering of the fibre. Hence the locality of $\mathcal{P}_2$
for the syntomic topology on the source follows from
Descent, Lemma \ref{descent-lemma-CM-local-syntomic}.
Combining the above the lemma follows.
\end{proof}






\section{Slicing Cohen-Macaulay morphisms}
\label{section-slicing-CM}

\noindent
The results in this section eventually lead to the assertion that
the fppf topology is the same as the
``finitely presented, flat, quasi-finite'' topology.
The following lemma is very closely related to
Divisors, Lemma \ref{divisors-lemma-fibre-Cartier}.

\begin{lemma}
\label{lemma-slice-given-element}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Let $h \in \mathfrak m_x \subset \mathcal{O}_{X, x}$.
Assume
\begin{enumerate}
\item $f$ is locally of finite presentation,
\item $f$ is flat at $x$, and
\item the image $\overline{h}$ of $h$ in
$\mathcal{O}_{X_s, x} = \mathcal{O}_{X, x}/\mathfrak m_s\mathcal{O}_{X, x}$
is a nonzerodivisor.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
such that $h$ comes from $h \in \Gamma(U, \mathcal{O}_U)$ and such
that $D = V(h)$ is an effective Cartier divisor in $U$ with $x \in D$ and
$D \to S$ flat and locally of finite presentation.
\end{lemma}

\begin{proof}
We are going to prove this by reducing to the Noetherian case.
By openness of flatness (see
Theorem \ref{theorem-openness-flatness})
we may assume, after replacing $X$ by an
open neighbourhood of $x$, that $X \to S$ is flat.
We may also assume that $X$ and $S$ are affine.
After possible shrinking $X$ a bit we may assume that there exists
an $h \in \Gamma(X, \mathcal{O}_X)$ which maps to our given $h$.

\medskip\noindent
We may write $S = \Spec(A)$ and we may write $A = \colim_i A_i$
as a directed colimit of finite type $\mathbf{Z}$ algebras.
Then by
Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}
or
Limits, Lemmas \ref{limits-lemma-descend-finite-presentation},
\ref{limits-lemma-descend-affine-finite-presentation}, and
\ref{limits-lemma-descend-finite-presentation}
we can find a cartesian diagram
$$
\xymatrix{
X \ar[r] \ar[d]_f & X_0 \ar[d]^{f_0} \\
S \ar[r] & S_0
}
$$
with $f_0$ flat and of finite presentation, $X_0$ affine, and
$S_0$ affine and Noetherian. Let $x_0 \in X_0$, resp.\ $s_0 \in S_0$
be the image of $x$, resp.\ $s$. We may also assume there exists an element
$h_0 \in \Gamma(X_0, \mathcal{O}_{X_0})$ which restricts to $h$ on $X$.
(If you used the algebra reference above then this is clear; if you used
the references to the chapter on limits then this follows from
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
by thinking of $h$ as a morphism $X \to \mathbf{A}^1_S$.)
Note that $\mathcal{O}_{X_s, x}$ is a localization of
$\mathcal{O}_{(X_0)_{s_0}, x_0} \otimes_{\kappa(s_0)} \kappa(s)$, so that
$\mathcal{O}_{(X_0)_{s_0}, x_0} \to \mathcal{O}_{X_s, x}$ is a flat
local ring map, in particular faithfully flat. Hence the image
$\overline{h}_0 \in \mathcal{O}_{(X_0)_{s_0}, x_0}$
is contained in $\mathfrak m_{(X_0)_{s_0}, x_0}$ and is a nonzerodivisor.
We claim that after replacing $X_0$ by a principal open neighbourhood of
$x_0$ the element $h_0$ is a nonzerodivisor in
$B_0 = \Gamma(X_0, \mathcal{O}_{X_0})$ such that $B_0/h_0B_0$ is flat
over $A_0 = \Gamma(S_0, \mathcal{O}_{S_0})$.
If so then
$$
0 \to B_0 \xrightarrow{h_0} B_0 \to B_0/h_0B_0 \to 0
$$
is a short exact sequence of flat $A_0$-modules. Hence this remains exact
on tensoring with $A$ (by
Algebra, Lemma \ref{algebra-lemma-flat-tor-zero})
and the lemma follows.

\medskip\noindent
It remains to prove the claim above. The corresponding algebra statement
is the following (we drop the subscript ${}_0$ here):
Let $A \to B$ be a flat, finite type ring map of Noetherian rings.
Let $\mathfrak q \subset B$ be a prime lying over $\mathfrak p \subset A$.
Assume $h \in \mathfrak q$ maps to a nonzerodivisor in
$B_{\mathfrak q}/\mathfrak p B_{\mathfrak q}$.
Goal: show that after possible replacing $B$ by $B_g$ for some
$g \in B$, $g \not \in \mathfrak q$ the element $h$ becomes a nonzerodivisor
and $B/hB$ becomes flat over $A$. By
Algebra, Lemma \ref{algebra-lemma-grothendieck}
we see that $h$ is a nonzerodivisor in $B_{\mathfrak q}$ and that
$B_{\mathfrak q}/hB_{\mathfrak q}$ is flat over $A$.
By openness of flatness, see
Algebra, Theorem \ref{algebra-theorem-openness-flatness}
or
Theorem \ref{theorem-openness-flatness}
we see that $B/hB$ is flat over $A$ after replacing $B$ by $B_g$ for some
$g \in B$, $g \not \in \mathfrak q$. Finally, let
$I = \{b \in B \mid hb = 0\}$ be the annihilator of $h$. Then
$IB_{\mathfrak q} = 0$ as $h$ is a nonzerodivisor in $B_{\mathfrak q}$.
Also $I$ is finitely generated as $B$ is Noetherian.
Hence there exists a $g \in B$, $g \not \in \mathfrak q$ such that $IB_g = 0$.
After replacing $B$ by $B_g$ we see that $h$ is a nonzerodivisor.
\end{proof}

\begin{lemma}
\label{lemma-slice-given-elements}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Let $h_1, \ldots, h_r \in \mathcal{O}_{X, x}$.
Assume
\begin{enumerate}
\item $f$ is locally of finite presentation,
\item $f$ is flat at $x$, and
\item the images of $h_1, \ldots, h_r$ in
$\mathcal{O}_{X_s, x} = \mathcal{O}_{X, x}/\mathfrak m_s\mathcal{O}_{X, x}$
form a regular sequence.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
such that $h_1, \ldots, h_r$ come from
$h_1, \ldots, h_r \in \Gamma(U, \mathcal{O}_U)$ and such
that $Z = V(h_1, \ldots, h_r) \to U$ is a regular immersion with
$x \in Z$ and $Z \to S$ flat and locally of finite presentation.
Moreover, the base change $Z_{S'} \to U_{S'}$ is a regular immersion
for any scheme $S'$ over $S$.
\end{lemma}

\begin{proof}
(Our conventions on regular sequences imply that $h_i \in \mathfrak m_x$
for each $i$.) The case $r = 1$ follows from
Lemma \ref{lemma-slice-given-element}
combined with
Divisors, Lemma \ref{divisors-lemma-relative-Cartier}
to see that $V(h_1)$ remains an effective Cartier divisor after base change.
The case $r > 1$ follows from a straightforward induction on $r$ (applying
the result for $r = 1$ exactly $r$ times; details omitted).

\medskip\noindent
Another way to prove the lemma is using the material from
Divisors, Section \ref{divisors-section-relative-regular-immersion}.
Namely, first by openness of flatness (see
Theorem \ref{theorem-openness-flatness})
we may assume, after replacing $X$ by an
open neighbourhood of $x$, that $X \to S$ is flat.
We may also assume that $X$ and $S$ are affine.
After possible shrinking $X$ a bit we may assume that we have
$h_1, \ldots, h_r \in \Gamma(X, \mathcal{O}_X)$. Set
$Z = V(h_1, \ldots, h_r)$. Note that $X_s$ is a Noetherian scheme
(because it is an algebraic $\kappa(s)$-scheme, see
Varieties, Section \ref{varieties-section-algebraic-schemes})
and that the topology on $X_s$ is induced from the topology on $X$
(see
Schemes, Lemma \ref{schemes-lemma-fibre-topological}).
Hence after shrinking $X$ a bit more
we may assume that $Z_s \subset X_s$ is a regular immersion
cut out by the $r$ elements $h_i|_{X_s}$, see
Divisors, Lemma \ref{divisors-lemma-Noetherian-scheme-regular-ideal}
and its proof. It is also clear that $r = \dim_x(X_s) - \dim_x(Z_s)$ because
\begin{align*}
\dim_x(X_s) & = \dim(\mathcal{O}_{X_s, x}) +
\text{trdeg}_{\kappa(s)}(\kappa(x)), \\
\dim_x(Z_s) & = \dim(\mathcal{O}_{Z_s, x}) +
\text{trdeg}_{\kappa(s)}(\kappa(x)), \\
\dim(\mathcal{O}_{X_s, x}) & = \dim(\mathcal{O}_{Z_s, x}) + r
\end{align*}
the first two equalities by
Algebra, Lemma \ref{algebra-lemma-dimension-at-a-point-finite-type-field}
and the second by $r$ times applying
Algebra, Lemma \ref{algebra-lemma-one-equation}.
Hence
Divisors, Lemma \ref{divisors-lemma-fibre-quasi-regular} part (3)
applies to show that (after Zariski shrinking $X$) the morphism
$Z \to X$ is a regular immersion to which
Divisors, Lemma
\ref{divisors-lemma-relative-regular-immersion-flat-in-neighbourhood}
applies (which gives the flatness and the statement on base change).
\end{proof}

\begin{lemma}
\label{lemma-slice-once}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Assume
\begin{enumerate}
\item $f$ is locally of finite presentation,
\item $f$ is flat at $x$, and
\item $\mathcal{O}_{X_s, x}$ has $\text{depth} \geq 1$.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
and an effective Cartier divisor $D \subset U$ containing $x$ such that
$D \to S$ is flat and of finite presentation.
\end{lemma}

\begin{proof}
Pick any $h \in \mathfrak m_x \subset \mathcal{O}_{X, x}$ which
maps to a nonzerodivisor in $\mathcal{O}_{X_s, x}$ and apply
Lemma \ref{lemma-slice-given-element}.
\end{proof}

\begin{lemma}
\label{lemma-slice-CM}
\begin{reference}
\cite[IV Proposition 17.16.1]{EGA}
\end{reference}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Assume
\begin{enumerate}
\item $f$ is locally of finite presentation,
\item $f$ is Cohen-Macaulay at $x$, and
\item $x$ is a closed point of $X_s$.
\end{enumerate}
Then there exists a regular immersion $Z \to X$ containing $x$ such that
\begin{enumerate}
\item[(a)] $Z \to S$ is flat and locally of finite presentation,
\item[(b)] $Z \to S$ is locally quasi-finite, and
\item[(c)] $Z_s = \{x\}$ set theoretically.
\end{enumerate}
\end{lemma}

\begin{proof}
We may and do replace $S$ by an affine open neighbourhood of $s$.
We will prove the lemma for affine $S$ by induction on $d = \dim_x(X_s)$.

\medskip\noindent
The case $d = 0$. In this case we show that we may take $Z$ to be
an open neighbourhood of $x$. (Note that an open immersion is
a regular immersion.) Namely, if $d = 0$, then $X \to S$
is quasi-finite at $x$, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-rel-dimension-0}.
Hence there exists an affine open neighbourhood $U \subset X$ such
that $U \to S$ is quasi-finite, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open}.
Thus after replacing $X$ by $U$ we see that the fibre $X_s$ is a finite
discrete set. Hence after replacing $X$ by a further affine open neighbourhood
of $X$ we see that $f^{-1}(\{s\}) = \{x\}$ (because the topology
on $X_s$ is induced from the topology on $X$, see
Schemes, Lemma \ref{schemes-lemma-fibre-topological}).
This proves the lemma in this case.

\medskip\noindent
Next, assume $d > 0$. Note that because $x$ is a closed point of its
fibre the extension $\kappa(x)/\kappa(s)$ is finite (by the
Hilbert Nullstellensatz, see
Morphisms, Lemma \ref{morphisms-lemma-closed-point-fibre-locally-finite-type}).
Thus we see
$$
\text{depth}(\mathcal{O}_{X_s, x}) = \dim(\mathcal{O}_{X_s, x}) = d > 0
$$
the first equality as $\mathcal{O}_{X_s, x}$ is Cohen-Macaulay and
the second by
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point}.
Thus we may apply
Lemma \ref{lemma-slice-once}
to find a diagram
$$
\xymatrix{
D \ar[r] \ar[rrd] & U \ar[r] \ar[rd] & X \ar[d] \\
& & S
}
$$
with $x \in D$. Note that
$\mathcal{O}_{D_s, x} = \mathcal{O}_{X_s, x}/(\overline{h})$ for some
nonzerodivisor $\overline{h}$, see
Divisors, Lemma \ref{divisors-lemma-relative-Cartier}.
Hence $\mathcal{O}_{D_s, x}$ is Cohen-Macaulay of dimension
one less than the dimension of $\mathcal{O}_{X_s, x}$, see
Algebra, Lemma \ref{algebra-lemma-reformulate-CM}
for example. Thus the morphism $D \to S$ is flat,
locally of finite presentation, and Cohen-Macaulay at $x$ with
$\dim_x(D_s) = \dim_x(X_s) - 1 = d - 1$. By induction hypothesis
we can find a regular immersion $Z \to D$ having properties (a), (b), (c).
As $Z \to D \to U$ are both regular immersions, we see that also
$Z \to U$ is a regular immersion by
Divisors, Lemma \ref{divisors-lemma-composition-regular-immersion}.
This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-qf-fp-flat-neighbourhood-dominates-fppf}
Let $f : X \to S$ be a flat morphism of schemes which is
locally of finite presentation. Let $s \in S$ be a point in the image of $f$.
Then there exists a commutative diagram
$$
\xymatrix{
S' \ar[rr] \ar[rd]_g & & X \ar[ld]^f \\
& S
}
$$
where $g : S' \to S$ is flat, locally of finite presentation,
locally quasi-finite, and $s \in g(S')$.
\end{lemma}

\begin{proof}
The fibre $X_s$ is not empty by assumption. Hence there exists a closed
point $x \in X_s$ where $f$ is Cohen-Macaulay, see
Lemma \ref{lemma-flat-finite-presentation-CM-open}.
Apply
Lemma \ref{lemma-slice-CM}
and set $S' = S$.
\end{proof}

\noindent
The following lemma shows that sheaves for the fppf topology are
the same thing as sheaves for the
``quasi-finite, flat, finite presentation'' topology.

\begin{lemma}
\label{lemma-qf-fp-flat-dominates-fppf}
Let $S$ be a scheme. Let $\mathcal{U} = \{S_i \to S\}_{i \in I}$ be an fppf
covering of $S$, see
Topologies, Definition \ref{topologies-definition-fppf-covering}.
Then there exists an fppf covering $\mathcal{V} = \{T_j \to S\}_{j \in J}$
which refines (see
Sites, Definition \ref{sites-definition-morphism-coverings})
$\mathcal{U}$ such that each $T_j \to S$ is locally quasi-finite.
\end{lemma}

\begin{proof}
For every $s \in S$ there exists an $i \in I$ such that $s$ is in
the image of $S_i \to S$. By
Lemma \ref{lemma-qf-fp-flat-neighbourhood-dominates-fppf}
we can find a morphism $g_s : T_s \to S$ such that $s \in g_s(T_s)$
which is flat, locally of finite presentation and locally quasi-finite
and such that $g_s$ factors through $S_i \to S$. Hence
$\{T_s \to S\}$ is the desired covering of $S$ that refines $\mathcal{U}$.
\end{proof}



\section{Generic fibres}
\label{section-generic}

\noindent
Some results on the relationship between generic fibres and
nearby fibres.

\begin{lemma}
\label{lemma-empty-generic-fibre}
Let $f : X \to Y$ be a finite type morphism of schemes. Assume
$Y$ irreducible with generic point $\eta$. If $X_\eta = \emptyset$
then there exists a nonempty open $V \subset Y$ such that
$X_V = V \times_Y X = \emptyset$.
\end{lemma}

\begin{proof}
Follows immediately from the more general
Morphisms,
Lemma \ref{morphisms-lemma-quasi-compact-generic-point-not-in-image}.
\end{proof}

\begin{lemma}
\label{lemma-nonempty-generic-fibre}
Let $f : X \to Y$ be a finite type morphism of schemes. Assume
$Y$ irreducible with generic point $\eta$. If $X_\eta \not = \emptyset$
then there exists a nonempty open $V \subset Y$ such that
$X_V = V \times_Y X \to V$ is surjective.
\end{lemma}

\begin{proof}
This follows, upon taking affine opens, from
Algebra, Lemma \ref{algebra-lemma-characterize-image-finite-type}.
(Of course it also follows from generic flatness.)
\end{proof}

\begin{lemma}
\label{lemma-nowhere-dense-generic-fibre}
Let $f : X \to Y$ be a finite type morphism of schemes. Assume
$Y$ irreducible with generic point $\eta$.
If $Z \subset X$ is a closed subset with $Z_\eta$ nowhere dense
in $X_\eta$, then there exists a nonempty open $V \subset Y$ such
that $Z_y$ is nowhere dense in $X_y$ for all $y \in V$.
\end{lemma}

\begin{proof}
Let $Y' \subset Y$ be the reduction of $Y$.
Set $X' = Y' \times_Y X$ and $Z' = Y' \times_Y Z$.
As $Y' \to Y$ is a universal homeomorphism by
Morphisms, Lemma \ref{morphisms-lemma-reduction-universal-homeomorphism}
we see that it suffices to prove the lemma for $Z' \subset X' \to Y'$.
Thus we may assume that $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
By
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}
there exists a nonempty affine open $V \subset Y$ such that
$X_V \to V$ and $Z_V \to V$ are flat and of finite presentation.
We claim that $V$ works.
Pick $y \in V$. If $Z_y$ has a nonempty interior, then $Z_y$ contains
a generic point $\xi$ of an irreducible component of $X_y$.
Note that $\eta \leadsto f(\xi)$. Since $Z_V \to V$ is flat we can
choose a specialization $\xi' \leadsto \xi$, $\xi' \in Z$
with $f(\xi') = \eta$, see
Morphisms, Lemma \ref{morphisms-lemma-generalizations-lift-flat}.
By
Lemma \ref{lemma-flat-finite-presentation-specialization-dimension}
we see that
$$
\dim_{\xi'}(Z_\eta) = \dim_{\xi}(Z_y) = \dim_{\xi}(X_y) = \dim_{\xi'}(X_\eta).
$$
Hence some irreducible component of $Z_\eta$ passing through $\xi'$ has
dimension $\dim_{\xi'}(X_\eta)$ which contradicts the assumption that
$Z_\eta$ is nowhere dense in $X_\eta$ and we win.
\end{proof}

\begin{lemma}
\label{lemma-scheme-theoretically-dense-generic-fibre}
Let $f : X \to Y$ be a finite type morphism of schemes.
Assume $Y$ irreducible with generic point $\eta$.
Let $U \subset X$ be an open subscheme such that $U_\eta$ is
scheme theoretically dense in $X_\eta$.
Then there exists a nonempty open $V \subset Y$ such
that $U_y$ is scheme theoretically dense in $X_y$ for all $y \in V$.
\end{lemma}

\begin{proof}
Let $Y' \subset Y$ be the reduction of $Y$.
Let $X' = Y' \times_Y X$ and $U' = Y' \times_Y U$.
As $Y' \to Y$ induces a bijection on points, and as
$U' \to U$ and $X' \to X$ induce isomorphisms of scheme theoretic fibres,
we may replace $Y$ by $Y'$ and $X$ by $X'$.
Thus we may assume that $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
We may also replace $Y$ by a nonempty affine open. In other words we
may assume that $Y = \Spec(A)$ where $A$ is a domain with fraction
field $K$.

\medskip\noindent
As $f$ is of finite type we see that $X$ is quasi-compact.
Write $X = X_1 \cup \ldots \cup X_n$ for some affine opens $X_i$. By
Morphisms, Definition \ref{morphisms-definition-scheme-theoretically-dense}
we see that $U_i = X_i \cap U$ is an open subscheme of $X_i$ such that
$U_{i, \eta}$ is scheme theoretically dense in $X_{i, \eta}$.
Thus it suffices to prove the result for the pairs $(X_i, U_i)$,
in other words we may assume that $X$ is affine.

\medskip\noindent
Write $X = \Spec(B)$. Note that $B_K$ is Noetherian as it is a
finite type $K$-algebra. Hence $U_\eta$ is quasi-compact. Thus we can
find finitely many $g_1, \ldots, g_m \in B$ such that $D(g_j) \subset U$
and such that $U_\eta = D(g_1)_\eta \cup \ldots \cup D(g_m)_\eta$.
The fact that $U_\eta$ is scheme theoretically dense in
$X_\eta$ means that $B_K \to \bigoplus_j (B_K)_{g_j}$
is injective, see
Morphisms, Example \ref{morphisms-example-scheme-theoretic-closure}.
By
Algebra, Lemma \ref{algebra-lemma-when-injective-covering}
this is equivalent to the injectivity of
$B_K \to \bigoplus\nolimits_{j = 1, \ldots, m} B_K$,
$b \mapsto (g_1b, \ldots, g_mb)$. Let $M$ be the cokernel of this
map over $A$, i.e., such that we have an exact sequence
$$
0 \to I \to B \xrightarrow{(g_1, \ldots, g_m)}
\bigoplus\nolimits_{j = 1, \ldots, m} B \to M \to 0
$$
After replacing $A$ by $A_h$ for some nonzero $h$ we may assume that $B$
is a flat, finitely presented $A$-algebra, and that $M$
is flat over $A$, see
Algebra, Lemma \ref{algebra-lemma-generic-flatness}.
The flatness of $B$ over $A$ implies that $B$ is torsion free as an
$A$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-flat-torsion-free}.
Hence $B \subset B_K$. By assumption $I_K = 0$ which implies that $I = 0$
(as $I \subset B \subset B_K$ is a subset of $I_K$). Hence now
we have a short exact sequence
$$
0 \to B \xrightarrow{(g_1, \ldots, g_m)}
\bigoplus\nolimits_{j = 1, \ldots, m} B \to M \to 0
$$
with $M$ flat over $A$. Hence for every homomorphism $A \to \kappa$ where
$\kappa$ is a field, we obtain a short exact sequence
$$
0 \to B \otimes_A \kappa \xrightarrow{(g_1 \otimes 1, \ldots, g_m \otimes 1)}
\bigoplus\nolimits_{j = 1, \ldots, m} B \otimes_A \kappa \to
M \otimes_A \kappa \to 0
$$
see
Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}.
Reversing the arguments above
this means that $\bigcup D(g_j \otimes 1)$ is scheme
theoretically dense in $\Spec(B \otimes_A \kappa)$.
As $\bigcup D(g_j \otimes 1) = \bigcup D(g_j)_\kappa \subset U_\kappa$
we obtain that $U_\kappa$ is scheme theoretically dense in $X_\kappa$
which is what we wanted to prove.
\end{proof}

\noindent
Suppose given a morphism of schemes $f : X \to Y$ and
a point $y \in Y$. Recall that the fibre $X_y$ is homeomorphic
to the subset $f^{-1}(\{y\})$ of $X$ with induced topology, see
Schemes, Lemma \ref{schemes-lemma-fibre-topological}.
Suppose given a closed subset $T(y) \subset X_y$.
Let $T$ be the closure of $T(y)$ in $X$.
Endow $T$ with the induced reduced scheme structure.
Then $T$ is a closed subscheme of $X$ with the property
that $T_y = T(y)$ set-theoretically. In fact $T$ is the smallest
closed subscheme of $X$ with this property. Thus it is ``harmless''
to denote a closed subset of $X_y$ by $T_y$ if we so desire.
In the following lemma we apply this to the generic fibre of $f$.

\begin{lemma}
\label{lemma-cover-generic-fibre-neighbourhood}
Let $f : X \to Y$ be a finite type morphism of schemes. Assume
$Y$ irreducible with generic point $\eta$. Let
$X_\eta = Z_{1, \eta} \cup \ldots \cup Z_{n, \eta}$ be a covering of
the generic fibre by closed subsets of $X_\eta$.
Let $Z_i$ be the closure of $Z_{i, \eta}$ in $X$ (see discussion above).
Then there exists a nonempty open $V \subset Y$ such
that $X_y = Z_{1, y} \cup \ldots \cup Z_{n, y}$ for all $y \in V$.
\end{lemma}

\begin{proof}
If $Y$ is Noetherian then $U = X \setminus (Z_1 \cup \ldots \cup Z_n)$
is of finite type over $Y$ and we can directly apply
Lemma \ref{lemma-empty-generic-fibre}
to get that $U_V = \emptyset$ for a nonempty open $V \subset Y$.
In general we argue as follows. As the question is topological
we may replace $Y$ by its reduction. Thus $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
After shrinking $Y$ we may assume that $X \to Y$ is flat, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.
In this case every point $x$ in $X_y$ is a specialization of a point
$x' \in X_\eta$ by
Morphisms, Lemma \ref{morphisms-lemma-generalizations-lift-flat}.
As the $Z_i$ are closed in $X$ and cover the generic fibre this
implies that $X_y = \bigcup Z_{i, y}$ for $y \in Y$ as desired.
\end{proof}

\noindent
The following lemma says that generic fibres of morphisms whose source is
reduced are reduced.

\begin{lemma}
\label{lemma-reduction-generic-fibre}
Let $f : X \to Y$ be a morphism of schemes. Let $\eta \in Y$ be a generic
point of an irreducible component of $Y$. Then
$(X_\eta)_{red} = (X_{red})_\eta$.
\end{lemma}

\begin{proof}
Choose an affine neighbourhood $\Spec(A) \subset Y$ of $\eta$.
Choose an affine open $\Spec(B) \subset X$ mapping into $\Spec(A)$
via the morphism $f$. Let $\mathfrak p \subset A$ be the minimal prime
corresponding to $\eta$. Let $B_{red}$ be the quotient of $B$ by
the nilradical $\sqrt{(0)}$. The algebraic content of the lemma is that
$C = B_{red} \otimes_A \kappa(\mathfrak p)$ is reduced.
Denote $I \subset A$ the nilradical so that $A_{red} = A/I$.
Denote $\mathfrak p_{red} = \mathfrak p/I$
which is a minimal prime of $A_{red}$ with
$\kappa(\mathfrak p) = \kappa(\mathfrak p_{red})$.
Since $A \to B_{red}$ and $A \to \kappa(\mathfrak p)$
both factor through $A \to A_{red}$ we have
$C = B_{red} \otimes_{A_{red}} \kappa(\mathfrak p_{red})$.
Now $\kappa(\mathfrak p_{red}) = (A_{red})_{\mathfrak p_{red}}$
is a localization by 
Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}.
Hence $C$ is a localization of $B_{red}$
(Algebra, Lemma \ref{algebra-lemma-tensor-localization})
and hence reduced.
\end{proof}

\begin{lemma}
\label{lemma-make-generic-fibre-geometrically-reduced}
Let $f : X \to Y$ be a morphism of schemes.
Assume that $Y$ is irreducible and $f$ is of finite type.
There exists a diagram
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\
Y' \ar[r]^g & V \ar[r] & Y
}
$$
where
\begin{enumerate}
\item $V$ is a nonempty open of $Y$,
\item $X_V = V \times_Y X$,
\item $g : Y' \to V$ is a finite universal homeomorphism,
\item $X' = (Y' \times_Y X)_{red} = (Y' \times_V X_V)_{red}$,
\item $g'$ is a finite universal homeomorphism,
\item $Y'$ is an integral affine scheme,
\item $f'$ is flat and of finite presentation, and
\item the generic fibre of $f'$ is geometrically reduced.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $V = \Spec(A)$ be a nonempty affine open of $Y$.
By assumption the Jacobson radical of $A$ is a prime ideal $\mathfrak p$.
Let $K = \kappa(\mathfrak p)$.
Let $p$ be the characteristic of $K$ if positive and $1$
if the characteristic is zero. By
Varieties, Lemma \ref{varieties-lemma-finite-extension-geometrically-reduced}
there exists a finite purely inseparable field extension
$K'/K$ such that $X_{K'}$ is geometrically reduced over $K'$.
Choose elements $x_1, \ldots, x_n \in K'$ which generate $K'$ over
$K$ and such that some $p$-power of $x_i$ is in $A/\mathfrak p$.
Let $A' \subset K'$ be the finite $A$-subalgebra of $K'$ generated by
$x_1, \ldots, x_n$. Note that $A'$ is a domain with fraction field $K'$. By
Algebra, Lemma \ref{algebra-lemma-p-ring-map}
we see that $A \to A'$ is a universal homeomorphism.
Set $Y' = \Spec(A')$. Set $X' = (Y' \times_Y X)_{red}$.
The generic fibre of $X' \to Y'$ is $(X_K)_{red}$ by
Lemma \ref{lemma-reduction-generic-fibre}
which is geometrically reduced by construction.
Note that $X' \to X_V$ is a finite universal homeomorphism as the
composition of the reduction morphism $X' \to Y' \times_Y X$ (see
Morphisms, Lemma \ref{morphisms-lemma-reduction-universal-homeomorphism})
and the base change of $g$.
At this point all of the properties of the lemma hold except for
possibly (7). This can be achieved by shrinking $Y'$ and hence $V$, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.
\end{proof}

\begin{lemma}
\label{lemma-make-components-generic-fibre-geometrically-irreducible}
Let $f : X \to Y$ be a morphism of schemes.
Assume that $Y$ is irreducible and $f$ is of finite type.
There exists a diagram
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\
Y' \ar[r]^g & V \ar[r] & Y
}
$$
where
\begin{enumerate}
\item $V$ is a nonempty open of $Y$,
\item $X_V = V \times_Y X$,
\item $g : Y' \to V$ is surjective finite \'etale,
\item $X' = Y' \times_Y X = Y' \times_V X_V$,
\item $g'$ is surjective finite \'etale,
\item $Y'$ is an irreducible affine scheme, and
\item all irreducible components of the generic fibre of $f'$
are geometrically irreducible.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $V = \Spec(A)$ be a nonempty affine open of $Y$.
By assumption the Jacobson radical of $A$ is a prime ideal $\mathfrak p$.
Let $K = \kappa(\mathfrak p)$. By
Varieties, Lemma
\ref{varieties-lemma-finite-extension-geometrically-irreducible-components}
there exists a finite separable field extension
$K'/K$ such that all irreducible components of $X_{K'}$ are
geometrically irreducible over $K'$.
Choose an element $\alpha \in K'$ which generates $K'$ over
$K$, see
Fields, Lemma \ref{fields-lemma-primitive-element}.
Let $P(T) \in K[T]$ be the minimal polynomial for $\alpha$ over $K$.
After replacing $\alpha$ by $f \alpha$ for some
$f \in A$, $f \not \in \mathfrak p$
we may assume that there exists a monic polynomial
$T^d + a_1T^{d - 1} + \ldots + a_d \in A[T]$ which maps to
$P(T) \in K[T]$ under the map $A[T] \to K[T]$.
Set $A' = A[T]/(P)$. Then $A \to A'$ is a finite free ring map
such that there exists a unique prime $\mathfrak q$ lying over
$\mathfrak p$, such that
$K = \kappa(\mathfrak p) \subset \kappa(\mathfrak q) = K'$
is finite separable, and such that $\mathfrak pA'_{\mathfrak q}$
is the maximal ideal of $A'_{\mathfrak q}$.
Hence $g : Y' = \Spec(A') \to V = \Spec(A)$
is \'etale at $\mathfrak q$, see
Algebra, Lemma \ref{algebra-lemma-characterize-etale}.
This means that there exists an open $W \subset \Spec(A')$ such
that $g|_W : W \to \Spec(A)$ is \'etale.
Since $g$ is finite and since $\mathfrak q$ is the only point lying over
$\mathfrak p$ we see that $Z = g(Y' \setminus W)$ is a closed subset of $V$
not containing $\mathfrak p$. Hence after replacing $V$ by a principal
affine open of $V$ which does not meet $Z$ we obtain that $g$ is finite
\'etale.
\end{proof}







\section{Relative assassins}
\label{section-assassin}

\begin{lemma}
\label{lemma-relative-assassin-in-neighbourhood}
Let $f : X \to S$ be a morphism of schemes.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Let $\xi \in \text{Ass}_{X/S}(\mathcal{F})$ and set
$Z = \overline{\{\xi\}} \subset X$.
If $f$ is locally of finite type and $\mathcal{F}$ is a
finite type $\mathcal{O}_X$-module, then there exists a nonempty
open $V \subset Z$ such that for every $s \in f(V)$ the generic
points of $V_s$ are elements of $\text{Ass}_{X/S}(\mathcal{F})$.
\end{lemma}

\begin{proof}
We may replace $S$ by an affine open neighbourhood of $f(\xi)$
and $X$ by an affine open neighbourhood of $\xi$. Hence we may assume
$S = \Spec(A)$, $X = \Spec(B)$ and that $f$ is given by
the finite type ring map $A \to B$, see
Morphisms, Lemma \ref{morphisms-lemma-locally-finite-type-characterize}.
Moreover, we may write $\mathcal{F} = \widetilde{M}$ for some finite
$B$-module $M$, see
Properties, Lemma \ref{properties-lemma-finite-type-module}.
Let $\mathfrak q \subset B$ be the prime corresponding to $\xi$ and
let $\mathfrak p \subset A$ be the corresponding prime of $A$.
By assumption $\mathfrak q \in \text{Ass}_B(M \otimes_A \kappa(\mathfrak p))$,
see
Algebra, Remark \ref{algebra-remark-bourbaki}
and
Divisors, Lemma \ref{divisors-lemma-associated-affine-open}.
With this notation $Z = V(\mathfrak q) \subset \Spec(B)$.
In particular $f(Z) \subset V(\mathfrak p)$. Hence clearly it suffices to
prove the lemma after replacing $A$, $B$, and $M$ by
$A/\mathfrak pA$, $B/\mathfrak pB$, and $M/\mathfrak pM$.
In other words we may assume that $A$ is a domain with fraction field
$K$ and $\mathfrak q \subset B$ is an associated prime of $M \otimes_A K$.

\medskip\noindent
At this point we can use generic flatness. Namely, by
Algebra, Lemma \ref{algebra-lemma-generic-flatness}
there exists a nonzero $g \in A$ such that $M_g$ is flat
as an $A_g$-module. After replacing $A$ by $A_g$ we may assume that
$M$ is flat as an $A$-module.

\medskip\noindent
In this case, by
Algebra, Lemma \ref{algebra-lemma-post-bourbaki}
we see that $\mathfrak q$ is also an associated prime of $M$.
Hence we obtain an injective $B$-module map $B/\mathfrak q \to M$.
Let $Q$ be the cokernel so that we obtain a short exact sequence
$$
0 \to B/\mathfrak q \to M \to Q \to 0
$$
of finite $B$-modules. After applying generic flatness
Algebra, Lemma \ref{algebra-lemma-generic-flatness}
once more, this time to the $B$-module $Q$, we may assume that $Q$
is a flat $A$-module. In particular we may assume the short exact
sequence above is universally injective, see
Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}.
In this situation
$(B/\mathfrak q) \otimes_A \kappa(\mathfrak p')
\subset M \otimes_A \kappa(\mathfrak p')$
for any prime $\mathfrak p'$ of $A$. The lemma follows as a minimal
prime $\mathfrak q'$ of the support of
$(B/\mathfrak q) \otimes_A \kappa(\mathfrak p')$
is an associated prime of $(B/\mathfrak q) \otimes_A \kappa(\mathfrak p')$ by
Divisors, Lemma \ref{divisors-lemma-minimal-support-in-ass}.
\end{proof}

\begin{lemma}
\label{lemma-bad-case}
Let $f : X \to Y$ be a morphism of schemes. Let $\mathcal{F}$ be a
quasi-coherent $\mathcal{O}_X$-module. Let $U \subset X$ be an open
subscheme. Assume
\begin{enumerate}
\item $f$ is of finite type,
\item $\mathcal{F}$ is of finite type,
\item $Y$ is irreducible with generic point $\eta$, and
\item $\text{Ass}_{X_\eta}(\mathcal{F}_\eta)$ is not contained in $U_\eta$.
\end{enumerate}
Then there exists a nonempty open subscheme $V \subset Y$ such that
for all $y \in V$ the set $\text{Ass}_{X_y}(\mathcal{F}_y)$ is not
contained in $U_y$.
\end{lemma}

\begin{proof}
Let $Z \subset X$ be the scheme theoretic support of $\mathcal{F}$, see
Morphisms, Definition \ref{morphisms-definition-scheme-theoretic-support}.
Then $Z_\eta$ is the scheme theoretic support of $\mathcal{F}_\eta$
(Morphisms, Lemma \ref{morphisms-lemma-flat-pullback-support}).
Hence the generic points of irreducible components of $Z_\eta$
are contained in $\text{Ass}_{X_\eta}(\mathcal{F}_\eta)$ by
Divisors, Lemma \ref{divisors-lemma-minimal-support-in-ass}.
Hence we see that $Z_\eta \cap U_\eta = \emptyset$.
Thus $T = Z \setminus U$ is a closed subset of $Z$ with $T_\eta = \emptyset$.
If we endow $T$ with the induced reduced scheme structure then
$T \to Y$ is a morphism of finite type. By
Lemma \ref{lemma-empty-generic-fibre}
there is a nonempty open $V \subset Y$ with $T_V = \emptyset$.
Then $V$ works.
\end{proof}

\begin{lemma}
\label{lemma-good-case}
Let $f : X \to Y$ be a morphism of schemes. Let $\mathcal{F}$ be a
quasi-coherent $\mathcal{O}_X$-module. Let $U \subset X$ be an open
subscheme. Assume
\begin{enumerate}
\item $f$ is of finite type,
\item $\mathcal{F}$ is of finite type,
\item $Y$ is irreducible with generic point $\eta$, and
\item $\text{Ass}_{X_\eta}(\mathcal{F}_\eta) \subset U_\eta$.
\end{enumerate}
Then there exists a nonempty open subscheme $V \subset Y$ such that
for all $y \in V$ we have $\text{Ass}_{X_y}(\mathcal{F}_y) \subset U_y$.
\end{lemma}

\begin{proof}
(This proof is the same as the proof of
Lemma \ref{lemma-scheme-theoretically-dense-generic-fibre}.
We urge the reader to read that proof first.)
Since the statement is about fibres it is clear that we may replace
$Y$ by its reduction. Hence we may assume that $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
We may also assume that $Y = \Spec(A)$ is affine. Then $A$
is a domain with fraction field $K$.

\medskip\noindent
As $f$ is of finite type we see that $X$ is quasi-compact.
Write $X = X_1 \cup \ldots \cup X_n$ for some affine opens $X_i$
and set $\mathcal{F}_i = \mathcal{F}|_{X_i}$. By
assumption the generic fibre of $U_i = X_i \cap U$ contains
$\text{Ass}_{X_{i, \eta}}(\mathcal{F}_{i, \eta})$.
Thus it suffices to prove the result for the triples
$(X_i, \mathcal{F}_i, U_i)$,
in other words we may assume that $X$ is affine.

\medskip\noindent
Write $X = \Spec(B)$. Let $N$ be a finite $B$-module such that
$\mathcal{F} = \widetilde{N}$.
Note that $B_K$ is Noetherian as it is a
finite type $K$-algebra. Hence $U_\eta$ is quasi-compact. Thus we can
find finitely many $g_1, \ldots, g_m \in B$ such that $D(g_j) \subset U$
and such that $U_\eta = D(g_1)_\eta \cup \ldots \cup D(g_m)_\eta$.
Since $\text{Ass}_{X_\eta}(\mathcal{F}_\eta) \subset U_\eta$
we see that $N_K \to \bigoplus_j (N_K)_{g_j}$ is injective. By
Algebra, Lemma \ref{algebra-lemma-when-injective-covering}
this is equivalent to the injectivity of
$N_K \to \bigoplus\nolimits_{j = 1, \ldots, m} N_K$,
$n \mapsto (g_1n, \ldots, g_mn)$. Let $I$ and $M$ be the kernel and
cokernel of this map over $A$, i.e., such that we have an exact sequence
$$
0 \to I \to N \xrightarrow{(g_1, \ldots, g_m)}
\bigoplus\nolimits_{j = 1, \ldots, m} N \to M \to 0
$$
After replacing $A$ by $A_h$ for some nonzero $h$ we may assume that
$B$ is a flat, finitely presented $A$-algebra and that
both $M$ and $N$ are flat over $A$, see
Algebra, Lemma \ref{algebra-lemma-generic-flatness}.
The flatness of $N$ over $A$ implies that $N$ is torsion free as an
$A$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-flat-torsion-free}.
Hence $N \subset N_K$. By construction $I_K = 0$ which implies that $I = 0$
(as $I \subset N \subset N_K$ is a subset of $I_K$). Hence now
we have a short exact sequence
$$
0 \to N \xrightarrow{(g_1, \ldots, g_m)}
\bigoplus\nolimits_{j = 1, \ldots, m} N \to M \to 0
$$
with $M$ flat over $A$. Hence for every homomorphism $A \to \kappa$ where
$\kappa$ is a field, we obtain a short exact sequence
$$
0 \to N \otimes_A \kappa \xrightarrow{(g_1 \otimes 1, \ldots, g_m \otimes 1)}
\bigoplus\nolimits_{j = 1, \ldots, m} N \otimes_A \kappa \to
M \otimes_A \kappa \to 0
$$
see
Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}.
Reversing the arguments above
this means that $\bigcup D(g_j \otimes 1)$ contains
$\text{Ass}_{B \otimes_A \kappa}(N \otimes_A \kappa)$.
As $\bigcup D(g_j \otimes 1) = \bigcup D(g_j)_\kappa \subset U_\kappa$
we obtain that $U_\kappa$ contains
$\text{Ass}_{X \otimes \kappa}(\mathcal{F} \otimes \kappa)$
which is what we wanted to prove.
\end{proof}

\begin{lemma}
\label{lemma-base-change-assassin-in-U}
Let $f : X \to S$ be a morphism which is locally of finite type.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module
of finite type. Let $U \subset X$ be an open subscheme.
Let $g : S' \to S$ be a morphism of schemes, let
$f' : X' = X_{S'} \to S'$ be the base change of $f$,
let $g' : X' \to X$ be the projection, set
$\mathcal{F}' = (g')^*\mathcal{F}$, and set
$U' = (g')^{-1}(U)$. Finally, let $s' \in S'$ with image $s = g(s')$.
In this case
$$
\text{Ass}_{X_s}(\mathcal{F}_s) \subset U_s
\Leftrightarrow
\text{Ass}_{X'_{s'}}(\mathcal{F}'_{s'}) \subset U'_{s'}.
$$
\end{lemma}

\begin{proof}
This follows immediately from
Divisors, Lemma \ref{divisors-lemma-base-change-relative-assassin}.
See also
Divisors, Remark \ref{divisors-remark-base-change-relative-assassin}.
\end{proof}

\begin{lemma}
\label{lemma-relative-assassin-constructible}
Let $f : X \to Y$ be a morphism of finite presentation.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module
of finite presentation. Let $U \subset X$ be an open subscheme
such that $U \to Y$ is quasi-compact. Then the set
$$
E = \{y \in Y \mid \text{Ass}_{X_y}(\mathcal{F}_y) \subset U_y\}
$$
is locally constructible in $Y$.
\end{lemma}

\begin{proof}
Let $y \in Y$. We have to show that there exists an open neighbourhood
$V$ of $y$ in $Y$ such that $E \cap V$ is constructible in $V$. Thus we may
assume that $Y$ is affine. Write $Y = \Spec(A)$ and
$A = \colim A_i$ as a directed limit of finite type
$\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation whose base change to $Y$ recovers $f$.
After possibly increasing $i$ we may assume there exists a
quasi-coherent $\mathcal{O}_{X_i}$-module $\mathcal{F}_i$ of finite
presentation whose pullback to $X$ is isomorphic to $\mathcal{F}$, see
Limits, Lemma \ref{limits-lemma-descend-modules-finite-presentation}.
After possibly increasing $i$ one more time we may assume there exists
an open subscheme $U_i \subset X_i$ whose inverse image in $X$
is $U$, see
Limits, Lemma \ref{limits-lemma-descend-opens}.
By
Lemma \ref{lemma-base-change-assassin-in-U}
it suffices to prove the lemma for $f_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
We will use the criterion of
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}
to prove that $E$ is constructible in case $Y$ is a Noetherian scheme.
To see this let $Z \subset Y$ be an irreducible closed subscheme.
We have to show that $E \cap Z$ either contains a nonempty open subset
or is not dense in $Z$. This follows from
Lemmas \ref{lemma-bad-case} and
\ref{lemma-good-case}
applied to the base change $(X, \mathcal{F}, U) \times_Y Z$ over $Z$.
\end{proof}











\section{Reduced fibres}
\label{section-reduced}

\begin{lemma}
\label{lemma-nonreduced-in-neighbourhood}
Let $f : X \to Y$ be a morphism of schemes. Assume $Y$ irreducible with
generic point $\eta$ and $f$ of finite type. If $X_\eta$ is nonreduced,
then there exists a nonempty open $V \subset Y$
such that for all $y \in V$ the fibre $X_y$ is nonreduced.
\end{lemma}

\begin{proof}
Let $Y' \subset Y$ be the reduction of $Y$. Let $X' \to Y'$
be the base change of $f$. Note that $Y' \to Y$
induces a bijection on points and that $X' \to X$ identifies fibres.
Hence we may assume that $Y'$ is reduced, i.e., integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
We may also replace $Y$ by an affine open. Hence we may assume that
$Y = \Spec(A)$ with $A$ a domain. Denote $K$ the
fraction field of $A$.
Pick an affine open $\Spec(B) = U \subset X$ and a section
$h_\eta \in \Gamma(U_\eta, \mathcal{O}_{U_\eta}) = B_K$
which is nonzero and nilpotent.
After shrinking $Y$ we may assume that $h$ comes from
$h \in \Gamma(U, \mathcal{O}_U) = B$. After shrinking $Y$ a bit
more we may assume that $h$ is nilpotent. Let
$I = \{b \in B \mid hb = 0\}$ be the annihilator of $h$.
Then $C = B/I$ is a finite type $A$-algebra whose generic fiber
$(B/I)_K$ is nonzero (as $h_\eta \not = 0$). We apply
generic flatness to $A \to C$ and $A \to B/hB$, see
Algebra, Lemma \ref{algebra-lemma-generic-flatness},
and we obtain a $g \in A$, $g \not = 0$ such that $C_g$ is free as
an $A_g$-module and $(B/hB)_g$ is flat as an $A_g$-module.
Replace $Y$ by $D(g) \subset Y$. Now we have the short exact sequence
$$
0 \to C \to B \to B/hB \to 0.
$$
with $B/hB$ flat over $A$ and with $C$ nonzero free as an $A$-module.
It follows that for any homomorphism $A \to \kappa$ to a field
the ring $C \otimes_A \kappa$ is nonzero and the sequence
$$
0 \to C \otimes_A \kappa \to B \otimes_A \kappa \to
B/hB \otimes_A \kappa \to 0
$$
is exact, see
Algebra, Lemma \ref{algebra-lemma-flat-tor-zero}.
Note that
$B/hB \otimes_A \kappa = (B \otimes_A \kappa) / h(B \otimes_A \kappa)$
by right exactness of tensor product. Thus we conclude that
multiplication by $h$ is not zero on $B \otimes_A \kappa$.
This clearly means that for any point $y \in Y$ the element $h$
restricts to a nonzero element of $U_y$, whence $X_y$ is nonreduced.
\end{proof}

\begin{lemma}
\label{lemma-base-change-fibres-geometrically-reduced}
Let $f : X \to Y$ be a morphism of schemes.
Let $g : Y' \to Y$ be any morphism, and denote
$f' : X' \to Y'$ the base change of $f$.
Then
\begin{align*}
\{y' \in Y' \mid X'_{y'}\text{ is geometrically reduced}\} \\
= g^{-1}(\{y \in Y \mid X_y\text{ is geometrically reduced}\}).
\end{align*}
\end{lemma}

\begin{proof}
This comes down to the statement that for $y' \in Y'$ with image
$y \in Y$ the fibre $X'_{y'} = X_y \times_y y'$ is geometrically
reduced over $\kappa(y')$ if and only if $X_y$ is geometrically
reduced over $\kappa(y)$. This follows from
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-upstairs}.
\end{proof}

\begin{lemma}
\label{lemma-not-geometrically-reduced-in-neighbourhood}
Let $f : X \to Y$ be a morphism of schemes. Assume $Y$ irreducible with
generic point $\eta$ and $f$ of finite type. If $X_\eta$ is not
geometrically reduced, then there exists a nonempty open $V \subset Y$
such that for all $y \in V$ the fibre $X_y$ is not geometrically reduced.
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-make-generic-fibre-geometrically-reduced}
to get
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\
Y' \ar[r]^g & V \ar[r] & Y
}
$$
with all the properties mentioned in that lemma.
Let $\eta'$ be the generic point of $Y'$.
Consider the morphism $X' \to X_{Y'}$ (which is the reduction
morphism) and the resulting morphism of generic fibres
$X'_{\eta'} \to X_{\eta'}$.
Since $X'_{\eta'}$ is geometrically reduced, and $X_\eta$
is not this cannot be an isomorphism, see
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-upstairs}.
Hence $X_{\eta'}$ is nonreduced. Hence by
Lemma \ref{lemma-nonreduced-in-neighbourhood}
the fibres of $X_{Y'} \to Y'$ are nonreduced at all points $y' \in V'$
of a nonempty open $V' \subset Y'$. Since $g : Y' \to V$ is a homeomorphism
Lemma \ref{lemma-base-change-fibres-geometrically-reduced}
proves that $g(V')$ is the open we are looking for.
\end{proof}

\begin{lemma}
\label{lemma-geometrically-reduced-generic-fibre}
Let $f : X \to Y$ be a morphism of schemes.
Assume
\begin{enumerate}
\item $Y$ is irreducible with generic point $\eta$,
\item $X_\eta$ is geometrically reduced, and
\item $f$ is of finite type.
\end{enumerate}
Then there exists a nonempty open subscheme $V \subset Y$
such that $X_V \to V$ has geometrically reduced fibres.
\end{lemma}

\begin{proof}
Let $Y' \subset Y$ be the reduction of $Y$. Let $X' \to Y'$
be the base change of $f$. Note that $Y' \to Y$
induces a bijection on points and that $X' \to X$ identifies fibres.
Hence we may assume that $Y'$ is reduced, i.e., integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
We may also replace $Y$ by an affine open. Hence we may assume that
$Y = \Spec(A)$ with $A$ a domain. Denote $K$ the
fraction field of $A$. After shrinking $Y$ a bit we may also assume that
$X \to Y$ is flat and of finite presentation, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.

\medskip\noindent
As $X_\eta$ is geometrically reduced there exists an open dense
subset $V \subset X_\eta$ such that $V \to \Spec(K)$ is smooth, see
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-dense-smooth-open}.
Let $U \subset X$ be the set of points where $f$ is smooth. By
Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-smooth}
we see that $V \subset U_\eta$. Thus the generic fibre of $U$ is dense
in the generic fibre of $X$. Since $X_\eta$ is reduced, it follows
that $U_\eta$ is scheme theoretically dense in $X_\eta$, see
Morphisms, Lemma \ref{morphisms-lemma-reduced-scheme-theoretically-dense}.
We note that as $U \to Y$ is smooth all the fibres of $U \to Y$
are geometrically reduced. Thus it suffices to show that, after
shrinking $Y$, for all $y \in Y$ the scheme $U_y$ is scheme theoretically
dense in $X_y$, see
Morphisms, Lemma \ref{morphisms-lemma-reduced-subscheme-closure}.
This follows from
Lemma \ref{lemma-scheme-theoretically-dense-generic-fibre}.
\end{proof}

\begin{lemma}
\label{lemma-geometrically-reduced-constructible}
Let $f : X \to Y$ be a morphism which is quasi-compact and
locally of finite presentation. Then the set
$$
E = \{y \in Y \mid X_y\text{ is geometrically reduced}\}
$$
is locally constructible in $Y$.
\end{lemma}

\begin{proof}
Let $y \in Y$. We have to show that there exists an open neighbourhood
$V$ of $y$ in $Y$ such that $E \cap V$ is constructible in $V$. Thus we may
assume that $Y$ is affine. Then $X$ is quasi-compact.
Choose a finite affine open covering $X = U_1 \cup \ldots \cup U_n$.
Then the fibres of $U_i \to Y$ at $y$ form an affine open covering
of the fibre of $X \to Y$ at $y$. Hence we may assume $X$ is affine
as well.  Write $Y = \Spec(A)$.
Write $A = \colim A_i$ as a directed limit of finite type
$\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation whose base change to $Y$ recovers $f$. By
Lemma \ref{lemma-base-change-fibres-geometrically-reduced}
it suffices to prove the lemma for $f_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
We will use the criterion of
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}
to prove that $E$ is constructible in case $Y$ is a Noetherian scheme.
To see this let $Z \subset Y$ be an irreducible closed subscheme.
We have to show that $E \cap Z$ either contains a nonempty open subset
or is not dense in $Z$. If $X_\xi$ is geometrically reduced, then
Lemma \ref{lemma-geometrically-reduced-generic-fibre}
(applied to the morphism $X_Z \to Z$)
implies that all fibres $X_y$ are geometrically reduced
for a nonempty open $V \subset Z$.
If $X_\xi$ is not geometrically reduced, then
Lemma \ref{lemma-not-geometrically-reduced-in-neighbourhood}
(applied to the morphism $X_Z \to Z$)
implies that all fibres $X_y$ are geometrically reduced
for a nonempty open $V \subset Z$. Thus we win.
\end{proof}

\begin{lemma}
\label{lemma-proper-flat-over-dvr-reduced-fibre}
Let $X \to \Spec(R)$ be a proper flat morphism where $R$ is a
discrete valuation ring. If the special fibre is reduced, then
both $X$ and the generic fibre $X_\eta$ are reduced.
\end{lemma}

\begin{proof}
Let $x \in X$ be a point in the generic fibre $X_\eta$
such that $\mathcal{O}_{X_\eta}$ is nonreduced.
Then $\mathcal{O}_{X, x}$ is nonreduced.
Let $x \leadsto x'$ be a specialization with $x'$
in the special fibre; such a specialization exists
as a proper morphism is closed. Consider the local
ring $A = \mathcal{O}_{X, x'}$. Let $\pi \in R$ be a uniformizer.
If $a \in A$ then there exists an $n \geq 0$ and an element
$a' \in A$ such that $a = \pi^n a'$ and $a' \not \in \pi A$.
This follows from Krull intersection theorem
(Algebra, Lemma \ref{algebra-lemma-intersect-powers-ideal-module-zero}).
If $a$ is nilpotent, so is $a'$, because $\pi$ is a nonzerodivisor
by flatness of $A$ over $R$.
But $a'$ maps to a nonzero element of the reduced ring
$A/\pi A = \mathcal{O}_{X_s, x'}$.
This is a contradiction unless $A$ is reduced, which
is what we wanted to show.
\end{proof}

\begin{lemma}
\label{lemma-geometrically-reduced-open}
Let $f : X \to Y$ be a flat proper morphism of finite presentation.
Then the set $\{y \in Y \mid X_y\text{ is geometrically reduced}\}$
is open in $Y$.
\end{lemma}

\begin{proof}
We may assume $Y$ is affine. Then $Y$ is a cofiltered limit of affine
schemes of finite type over $\mathbf{Z}$.
Hence we can assume $X \to Y$ is the
base change of $X_0 \to Y_0$ where $Y_0$ is the spectrum of a finite
type $\mathbf{Z}$-algebra and $X_0 \to Y_0$ is flat and proper.
See Limits, Lemma \ref{limits-lemma-descend-finite-presentation},
\ref{limits-lemma-descend-flat-finite-presentation}, and
\ref{limits-lemma-eventually-proper}. Since the formation of
the set of points where the fibres are geometrically
reduced commutes with base change
(Lemma \ref{lemma-base-change-fibres-geometrically-reduced}),
we may assume the base is Noetherian.

\medskip\noindent
Assume $Y$ is Noetherian. The set is constructible by
Lemma \ref{lemma-geometrically-reduced-constructible}.
Hence it suffices to show the set is stable under generalization
(Topology, Lemma \ref{topology-lemma-characterize-closed-Noetherian}). By
Properties, Lemma \ref{properties-lemma-locally-Noetherian-specialization-dvr}
we reduce to the case where $Y = \Spec(R)$, $R$ is a discrete
valuation ring, and the closed fibre $X_y$ is geometrically
reduced. To show: the generic fibre $X_\eta$ is geometrically reduced.

\medskip\noindent
If not then there exists a finite extension $L$ of the fraction
field of $R$ such that $X_L$ is not reduced, see
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced}.
There exists a discrete valuation ring
$R' \subset L$ with fraction field $L$ dominating $R$, see
Algebra, Lemma \ref{algebra-lemma-integral-closure-Dedekind}.
After replacing $R$ by $R'$ we reduce to
Lemma \ref{lemma-proper-flat-over-dvr-reduced-fibre}.
\end{proof}







\section{Irreducible components of fibres}
\label{section-irreducible}

\begin{lemma}
\label{lemma-irreducible-components-in-neighbourhood}
Let $f : X \to Y$ be a morphism of schemes. Assume $Y$ irreducible with
generic point $\eta$ and $f$ of finite type. If $X_\eta$ has $n$
irreducible components, then there exists a nonempty open $V \subset Y$
such that for all $y \in V$ the fibre $X_y$ has at least $n$
irreducible components.
\end{lemma}

\begin{proof}
As the question is purely topological we may replace $X$ and $Y$ by
their reductions. In particular this implies that $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
Let $X_\eta = X_{1, \eta} \cup \ldots \cup X_{n, \eta}$
be the decomposition of $X_\eta$ into irreducible components.
Let $X_i \subset X$ be the reduced closed subscheme whose generic
fibre is $X_{i, \eta}$. Note that $Z_{i, j} = X_i \cap X_j$
is a closed subset of $X_i$ whose generic fibre $Z_{i, j, \eta}$
is nowhere dense in $X_{i, \eta}$. Hence after shrinking $Y$ we may
assume that $Z_{i, j, y}$
is nowhere dense in $X_{i, y}$ for every $y \in Y$, see
Lemma \ref{lemma-nowhere-dense-generic-fibre}.
After shrinking $Y$ some more we may assume that
$X_y = \bigcup X_{i, y}$ for $y \in Y$, see
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
Moreover, after shrinking $Y$ we may assume that each $X_i \to Y$
is flat and of finite presentation, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.
The morphisms $X_i \to Y$ are open, see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open}.
Thus there exists an open neighbourhood $V$ of $\eta$ which is contained
in $f(X_i)$ for each $i$.
For each $y \in V$ the schemes $X_{i, y}$ are
nonempty closed subsets of $X_y$, we have $X_y = \bigcup X_{i, y}$
and the intersections $Z_{i, j, y} = X_{i, y} \cap X_{j, y}$
are not dense in $X_{i, y}$. Clearly this implies that
$X_y$ has at least $n$ irreducible components.
\end{proof}

\begin{lemma}
\label{lemma-base-change-fibres-geometrically-irreducible}
Let $f : X \to Y$ be a morphism of schemes.
Let $g : Y' \to Y$ be any morphism, and denote
$f' : X' \to Y'$ the base change of $f$.
Then
\begin{align*}
\{y' \in Y' \mid X'_{y'}\text{ is geometrically irreducible}\} \\
= g^{-1}(\{y \in Y \mid X_y\text{ is geometrically irreducible}\}).
\end{align*}
\end{lemma}

\begin{proof}
This comes down to the statement that for $y' \in Y'$ with image
$y \in Y$ the fibre $X'_{y'} = X_y \times_y y'$ is geometrically
irreducible over $\kappa(y')$ if and only if $X_y$ is geometrically
irreducible over $\kappa(y)$. This follows from
Varieties,
Lemma \ref{varieties-lemma-geometrically-irreducible-check-after-extension}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-fibres-nr-geometrically-irreducible-components}
Let $f : X \to Y$ be a morphism of schemes. Let
$$
n_{X/Y} : Y \to \{0, 1, 2, 3, \ldots, \infty\}
$$
be the function which associates to $y \in Y$ the number of irreducible
components of $(X_y)_K$ where $K$ is a separably closed extension
of $\kappa(y)$. This is well defined and if $g : Y' \to Y$ is a morphism
then
$$
n_{X'/Y'} = n_{X/Y} \circ g
$$
where $X' \to Y'$ is the base change of $f$.
\end{lemma}

\begin{proof}
Suppose that $y' \in Y'$ has image $y \in Y$.
Suppose $K \supset \kappa(y)$ and $K' \supset \kappa(y')$ are separably
closed extensions. Then we may choose a commutative diagram
$$
\xymatrix{
K \ar[r] & K'' & K' \ar[l] \\
\kappa(y) \ar[u] \ar[rr] & & \kappa(y') \ar[u]
}
$$
of fields. The result follows as the morphisms of schemes
$$
\xymatrix{
(X'_{y'})_{K'} &
(X'_{y'})_{K''} = (X_y)_{K''} \ar[l] \ar[r] &
(X_y)_K
}
$$
induce bijections between irreducible components, see
Varieties,
Lemma \ref{varieties-lemma-separably-closed-field-irreducible-components}.
\end{proof}

\begin{lemma}
\label{lemma-irreducible-polynomial-over-domain}
Let $A$ be a domain with fraction field $K$.
Let $P \in A[x_1, \ldots, x_n]$.
Denote $\overline{K}$ the algebraic closure of $K$.
Assume $P$ is irreducible in $\overline{K}[x_1, \ldots, x_n]$.
Then there exists a $f \in A$ such that
$P^\varphi \in \kappa[x_1, \ldots, x_n]$ is irreducible for all
homomorphisms $\varphi : A_f \to \kappa$ into fields.
\end{lemma}

\begin{proof}
There exists an automorphism $\Psi$ of $A[x_1, \ldots, x_n]$ over $A$
such that $\Psi(P) = ax_n^d +$ lower order terms in $x_n$ with
$a \not = 0$, see
Algebra, Lemma \ref{algebra-lemma-helper-polynomial}.
We may replace $P$ by $\Psi(P)$ and we may replace $A$ by $A_a$.
Thus we may assume that $P$ is monic in $x_n$ of degree $d > 0$.
For $i = 1, \ldots, n - 1$ let $d_i$ be the degree of $P$ in $x_i$.
Note that this implies that $P^\varphi$ is monic of degree $d$ in $x_n$
and has degree $\leq d_i$ in $x_i$ for every homomorphism
$\varphi : A \to \kappa$ where $\kappa$ is a field.
Thus if $P^\varphi$ is reducible, then we can write
$$
P^\varphi = Q_1 Q_2
$$
with $Q_1, Q_2$ monic of degree $e_1, e_2 \geq 0$ in $x_n$ with
$e_1 + e_2 = d$ and having degree $\leq d_i$ in $x_i$ for
$i = 1, \ldots, n - 1$. In other words we can write
\begin{equation}
\label{equation-factors}
Q_j = x_n^{e_j} + \sum\nolimits_{0 \leq l < e_j}
\left( \sum\nolimits_{L \in \mathcal{L}} a_{j, l, L} x^L \right) x_n^l
\end{equation}
where the sum is over the set $\mathcal{L}$ of multi-indices $L$
of the form $L = (l_1, \ldots, l_{n - 1})$ with $0 \leq l_i \leq d_i$.
For any $e_1, e_2 \geq 0$ with $e_1 + e_2 = d$ we consider the $A$-algebra
$$
B_{e_1, e_2} =
A[\{a_{1, l, L}\}_{0 \leq l < e_1, L \in \mathcal{L}},
\{a_{2, l, L}\}_{0 \leq l < e_2, L \in \mathcal{L}}]/(\text{relations})
$$
where the $(\text{relations})$ is the ideal generated by the coefficients
of the polynomial
$$
P - Q_1Q_2 \in
A[\{a_{1, l, L}\}_{0 \leq l < e_1, L \in \mathcal{L}},
\{a_{2, l, L}\}_{0 \leq l < e_2, L \in \mathcal{L}}][x_1, \ldots, x_n]
$$
with $Q_1$ and $Q_2$ defined as in (\ref{equation-factors}). OK, and
the assumption that $P$ is irreducible over $\overline{K}$ implies that
there does not exist any $A$-algebra homomorphism
$B_{e_1, e_2} \to \overline{K}$. By the Hilbert Nullstellensatz, see
Algebra, Theorem \ref{algebra-theorem-nullstellensatz}
this means that $B_{e_1, e_2} \otimes_A K = 0$.
As $B_{e_1, e_2}$ is a finitely generated $A$-algebra this signifies that
we can find an $f_{e_1, e_2} \in A$ such that
$(B_{e_1, e_2})_{f_{e_1, e_2}} = 0$. By construction this means that
if $\varphi : A_{f_{e_1, e_2}} \to \kappa$ is a homomorphism to a field,
then $P^\varphi$ does not have a factorization $P^\varphi = Q_1 Q_2$
with $Q_1$ of degree $e_1$ in $x_n$ and $Q_2$ of degree $e_2$ in $x_n$.
Thus taking
$f = \prod_{e1, e_2 \geq 0, e_1 + e_2 = d} f_{e_1, e_2}$ we win.
\end{proof}

\begin{lemma}
\label{lemma-geom-irreducible-generic-fibre}
Let $f : X \to Y$ be a morphism of schemes.
Assume
\begin{enumerate}
\item $Y$ is irreducible with generic point $\eta$,
\item $X_\eta$ is geometrically irreducible, and
\item $f$ is of finite type.
\end{enumerate}
Then there exists a nonempty open subscheme $V \subset Y$
such that $X_V \to V$ has geometrically irreducible fibres.
\end{lemma}

\begin{proof}[First proof of Lemma \ref{lemma-geom-irreducible-generic-fibre}]
We give two proofs of the lemma. These are essentially equivalent;
the second is more self contained but a bit longer.
Choose a diagram
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\
Y' \ar[r]^g & V \ar[r] & Y
}
$$
as in
Lemma \ref{lemma-make-generic-fibre-geometrically-reduced}.
Note that the generic fibre of $f'$ is the reduction of the
generic fibre of $f$ (see
Lemma \ref{lemma-reduction-generic-fibre})
and hence is geometrically irreducible.
Suppose that the lemma holds for the morphism $f'$. Then after shrinking
$V$ all the fibres of $f'$ are geometrically irreducible.
As $X' = (Y' \times_V X_V)_{red}$ this implies that all the fibres
of $Y' \times_V X_V$ are geometrically irreducible. Hence by
Lemma \ref{lemma-base-change-fibres-geometrically-irreducible}
all the fibres of $X_V \to V$ are geometrically irreducible and
we win. In this way we see that we may assume that the generic
fibre is geometrically reduced as well as geometrically irreducible
and we may assume $Y = \Spec(A)$ with $A$ a domain.

\medskip\noindent
Let $x \in X_\eta$ be the generic point. As $X_\eta$ is geometrically
irreducible and reduced we see that $L = \kappa(x)$ is a finitely generated
extension of $K = \kappa(\eta)$ which is geometrically reduced and
geometrically irreducible, see
Varieties, Lemmas \ref{varieties-lemma-geometrically-reduced-at-point} and
\ref{varieties-lemma-geometrically-irreducible-function-field}.
In particular the field extension $L/K$ is separable, see
Algebra, Lemma \ref{algebra-lemma-characterize-separable-field-extensions}.
Hence we can find $x_1, \ldots, x_{r + 1} \in L$ which generate $L$
over $K$ and such that $x_1, \ldots, x_r$ is a transcendence basis for
$L$ over $K$, see
Algebra, Lemma
\ref{algebra-lemma-generating-finitely-generated-separable-field-extensions}.
Let $P \in K(x_1, \ldots, x_r)[T]$ be the minimal polynomial for
$x_{r + 1}$. Clearing denominators we may assume that
$P$ has coefficients in $A[x_1, \ldots, x_r]$.
Note that as $L$ is geometrically reduced and geometrically irreducible
over $K$, the polynomial $P$ is irreducible in
$\overline{K}[x_1, \ldots, x_r, T]$ where $\overline{K}$ is the
algebraic closure of $K$. Denote
$$
B' = A[x_1, \ldots, x_{r + 1}]/(P(x_{r + 1}))
$$
and set $X' = \Spec(B')$. By construction the fraction field of $B'$
is isomorphic to $L = \kappa(x)$ as $K$-extensions. Hence there exists an
open $U \subset X$, and open $U' \subset X'$ and a $Y$-isomorphism
$U \to U'$, see
Morphisms, Lemma \ref{morphisms-lemma-common-open}.
Here is a diagram:
$$
\xymatrix{
X \ar[rd] &
U \ar[l] \ar@{=}[r] \ar[d] &
U' \ar[r] \ar[d] &
X' \ar[ld] \ar@{=}[r] & \Spec(B') \\
& Y \ar@{=}[r] & Y &
}
$$
Note that $U_\eta \subset X_\eta$ and $U'_\eta \subset X'_\eta$ are
dense opens. Thus after shrinking $Y$ by applying
Lemma \ref{lemma-nowhere-dense-generic-fibre}
we obtain that $U_y$ is dense in $X_y$ and $U'_y$ is dense in $X'_y$
for all $y \in Y$. Thus it suffices to prove the lemma for
$X' \to Y$ which is the content of
Lemma \ref{lemma-irreducible-polynomial-over-domain}.
\end{proof}

\begin{proof}[Second proof of Lemma \ref{lemma-geom-irreducible-generic-fibre}]
Let $Y' \subset Y$ be the reduction of $Y$. Let $X' \to X$ be the reduction
of $X$. Note that $X' \to X  \to Y$ factors through $Y'$, see
Schemes, Lemma \ref{schemes-lemma-map-into-reduction}.
As $Y' \to Y$ and $X' \to X$ are universal
homeomorphisms by
Morphisms, Lemma \ref{morphisms-lemma-reduction-universal-homeomorphism}
we see that it suffices to prove the lemma for $X' \to Y'$. Thus
we may assume that $X$ and $Y$ are reduced. In particular $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
Thus by
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}
there exists a nonempty affine open $V \subset Y$ such that $X_V \to V$ is
flat and of finite presentation. After replacing $Y$ by $V$ we may
assume, in addition to (1), (2), (3) that $Y$ is integral affine, $X$
is reduced, and $f$ is flat and of finite presentation. In particular
$f$ is universally open, see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open}.

\medskip\noindent
Pick a nonempty affine open $U \subset X$. Then $U \to Y$ is flat and of
finite presentation with geometrically irreducible generic fibre.
The complement $X_\eta \setminus U_\eta$ is nowhere dense. Thus after
shrinking $Y$ we may assume $U_y \subset X_y$ is open dense for all
$y \in Y$, see
Lemma \ref{lemma-nowhere-dense-generic-fibre}.
Thus we may replace $X$ by $U$ and we reduce to the
case where $Y$ is integral affine and $X$ is reduced affine, flat and of finite
presentation over $Y$ with geometrically irreducible generic fibre $X_\eta$.

\medskip\noindent
Write $X = \Spec(B)$ and $Y = \Spec(A)$. Then $A$ is a domain,
$B$ is reduced, $A \to B$ is flat of finite presentation, and $B_K$ is
geometrically irreducible over the fraction field $K$ of $A$.
In particular we see that $B_K$ is a domain. Let $L$ be the fraction field
of $B_K$. Note that
$L$ is a finitely generated field extension of $K$ as $B$ is an $A$-algebra
of finite presentation. Let $K'/K$ be a finite purely inseparable
extension such that $(L \otimes_K K')_{red}$ is a separably generated field
extension, see
Algebra, Lemma \ref{algebra-lemma-make-separable}.
Choose $x_1, \ldots, x_n \in K'$ which generate the field extension
$K'$ over $K$, and such that $x_i^{q_i} \in A$ for some prime power
$q_i$ (proof existence $x_i$ omitted). Let $A'$ be the $A$-subalgebra
of $K'$ generated by $x_1, \ldots, x_n$. Then $A'$ is a finite
$A$-subalgebra $A' \subset K'$ whose fraction field is $K'$. Note that
$\Spec(A') \to \Spec(A)$ is a universal homeomorphism, see
Algebra, Lemma \ref{algebra-lemma-p-ring-map}.
Hence it suffices to prove the result after base changing to $\Spec(A')$.
We are going to replace $A$ by $A'$ and $B$ by $(B \otimes_A A')_{red}$
to arrive at the situation where $L$ is a separably generated field extension
of $K$. Of course it may happen that $(B \otimes_A A')_{red}$ is no longer
flat, or of finite presentation over $A'$, but this can be remedied by
replacing $A'$ by  $A'_f$ for a suitable $f \in A'$, see
Algebra, Lemma \ref{algebra-lemma-generic-flatness}.

\medskip\noindent
At this point we know that $A$ is a domain, $B$ is reduced, $A \to B$
is flat and of finite presentation, $B_K$ is a domain whose fraction field
$L$ is a separably generated field extension of the fraction field $K$
of $A$. By Algebra, Lemma
\ref{algebra-lemma-generating-finitely-generated-separable-field-extensions}
we may write $L = K(x_1, \ldots, x_{r + 1})$
where $x_1, \ldots, x_r$ are algebraically independent over $K$, and
$x_{r + 1}$ is separable over $K(x_1, \ldots, x_r)$. After clearing
denominators we may assume that the minimal polynomial
$P \in K(x_1, \ldots, x_r)[T]$ of $x_{r + 1}$ over $K(x_1, \ldots, x_r)$
has coefficients in $A[x_1, \ldots, x_r]$. Note that since
$L/K$ is separable and since $L$ is geometrically irreducible over
$K$, the polynomial $P$ is irreducible over the algebraic closure
$\overline{K}$ of $K$. Denote
$$
B' = A[x_1, \ldots, x_{r + 1}]/(P(x_{r + 1})).
$$
By construction the fraction fields of $B$ and $B'$ are isomorphic as
$K$-extensions. Hence there exists an isomorphism of $A$-algebras
$B_h \cong B'_{h'}$ for suitable $h \in B$ and $h' \in B'$, see
Morphisms, Lemma \ref{morphisms-lemma-common-open}.
In other words $X$ and $X' = \Spec(B')$ have a common affine open $U$.
Here is a diagram:
$$
\xymatrix{
X = \Spec(B) \ar[rd] &
U \ar[l] \ar[r] \ar[d] &
\Spec(B') = X' \ar[ld] \\
& Y = \Spec(A) &
}
$$
After shrinking $Y$ once more (by applying
Lemma \ref{lemma-nowhere-dense-generic-fibre}
to $Z = X \setminus U$ in $X$ and $Z' = X' \setminus U$ in $X'$)
we see that $U_y$ is dense in $X_y$ and $U_y$ is dense in $X'_y$
for all $y \in Y$. Thus it suffices to prove the lemma for
$X' \to Y$ which is the content of
Lemma \ref{lemma-irreducible-polynomial-over-domain}.
\end{proof}

\begin{lemma}
\label{lemma-nr-geom-irreducible-components-good}
Let $f : X \to Y$ be a morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ counting the numbers of geometrically
irreducible components of fibres of $f$ introduced in
Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}.
Assume $f$ of finite type.
Let $y \in Y$ be a point. Then there exists a nonempty open
$V \subset \overline{\{y\}}$ such that $n_{X/Y}|_V$ is constant.
\end{lemma}

\begin{proof}
Let $Z$ be the reduced induced scheme structure on $\overline{\{y\}}$.
Let $f_Z : X_Z \to Z$ be the base change of $f$. Clearly it suffices to prove
the lemma for $f_Z$ and the generic point of $Z$. Hence we may assume that
$Y$ is an integral scheme, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
Our goal in this case is to produce a nonempty open $V \subset Y$ such that
$n_{X/Y}|_V$ is constant.

\medskip\noindent
We apply
Lemma \ref{lemma-make-components-generic-fibre-geometrically-irreducible}
to $f : X \to Y$ and we get $g : Y' \to V \subset Y$. As $g : Y' \to V$ is
surjective finite \'etale, in particular open (see
Morphisms, Lemma \ref{morphisms-lemma-etale-open}),
it suffices to prove that there exists an open $V' \subset Y'$
such that $n_{X'/Y'}|_{V'}$ is constant, see
Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}.
Thus we see that we may assume that all irreducible components of
the generic fibre $X_\eta$ are geometrically irreducible over $\kappa(\eta)$.

\medskip\noindent
At this point suppose that
$X_\eta = X_{1, \eta} \bigcup \ldots \bigcup X_{n, \eta}$
is the decomposition of the generic fibre into
(geometrically) irreducible components.
In particular $n_{X/Y}(\eta) = n$.
Let $X_i$ be the closure of
$X_{i, \eta}$ in $X$. After shrinking $Y$ we may assume that
$X = \bigcup X_i$, see
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
After shrinking $Y$ some more we see that each fibre of
$f$ has at least $n$ irreducible components, see
Lemma \ref{lemma-irreducible-components-in-neighbourhood}.
Hence $n_{X/Y}(y) \geq n$ for all $y \in Y$.
After shrinking $Y$ some more we obtain that $X_{i, y}$
is geometrically irreducible for each $i$ and all $y \in Y$, see
Lemma \ref{lemma-geom-irreducible-generic-fibre}.
Since $X_y = \bigcup X_{i, y}$
this shows that $n_{X/Y}(y) \leq n$ and finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-nr-geom-irreducible-components-constructible}
Let $f : X \to Y$ be a morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ counting the numbers of geometrically
irreducible components of fibres of $f$ introduced in
Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}.
Assume $f$ of finite presentation. Then the level sets
$$
E_n = \{y \in Y \mid n_{X/Y}(y) = n\}
$$
of $n_{X/Y}$ are locally constructible in $Y$.
\end{lemma}

\begin{proof}
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood
$V$ of $y$ in $Y$ such that $E_n \cap V$ is constructible in $V$. Thus we may
assume that $Y$ is affine. Write $Y = \Spec(A)$ and
$A = \colim A_i$ as a directed limit of finite type
$\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation whose base change to $Y$ recovers $f$. By
Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}
it suffices to prove the lemma for $f_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
We will use the criterion of
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}
to prove that $E_n$ is constructible in case $Y$ is a Noetherian scheme.
To see this let $Z \subset Y$ be an irreducible closed subscheme.
We have to show that $E_n \cap Z$ either contains a nonempty open subset
or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then
Lemma \ref{lemma-nr-geom-irreducible-components-good}
shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$.
This clearly implies what we want.
\end{proof}













\section{Connected components of fibres}
\label{section-connected}

\begin{lemma}
\label{lemma-connected-components-in-neighbourhood}
Let $f : X \to Y$ be a morphism of schemes. Assume $Y$ irreducible with
generic point $\eta$ and $f$ of finite type. If $X_\eta$ has $n$
connected components, then there exists a nonempty open $V \subset Y$
such that for all $y \in V$ the fibre $X_y$ has at least $n$
connected components.
\end{lemma}

\begin{proof}
As the question is purely topological we may replace $X$ and $Y$ by
their reductions. In particular this implies that $Y$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
Let $X_\eta = X_{1, \eta} \cup \ldots \cup X_{n, \eta}$
be the decomposition of $X_\eta$ into connected components.
Let $X_i \subset X$ be the reduced closed subscheme whose generic
fibre is $X_{i, \eta}$. Note that $Z_{i, j} = X_i \cap X_j$
is a closed subset of $X$ whose generic fibre $Z_{i, j, \eta}$ is empty.
Hence after shrinking $Y$ we may assume that $Z_{i, j} = \emptyset$, see
Lemma \ref{lemma-empty-generic-fibre}.
After shrinking $Y$ some more we may assume that
$X_y = \bigcup X_{i, y}$ for $y \in Y$, see
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
Moreover, after shrinking $Y$ we may assume that each $X_i \to Y$
is flat and of finite presentation, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.
The morphisms $X_i \to Y$ are open, see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open}.
Thus there exists an open neighbourhood $V$ of $\eta$ which is contained
in $f(X_i)$ for each $i$.
For each $y \in V$ the schemes $X_{i, y}$ are
nonempty closed subsets of $X_y$, we have $X_y = \bigcup X_{i, y}$
and the intersections $Z_{i, j, y} = X_{i, y} \cap X_{j, y}$
are empty! Clearly this implies that
$X_y$ has at least $n$ connected components.
\end{proof}

\begin{lemma}
\label{lemma-base-change-fibres-geometrically-connected}
Let $f : X \to Y$ be a morphism of schemes.
Let $g : Y' \to Y$ be any morphism, and denote
$f' : X' \to Y'$ the base change of $f$.
Then
\begin{align*}
\{y' \in Y' \mid X'_{y'}\text{ is geometrically connected}\} \\
= g^{-1}(\{y \in Y \mid X_y\text{ is geometrically connected}\}).
\end{align*}
\end{lemma}

\begin{proof}
This comes down to the statement that for $y' \in Y'$ with image
$y \in Y$ the fibre $X'_{y'} = X_y \times_y y'$ is geometrically
connected over $\kappa(y')$ if and only if $X_y$ is geometrically connected
over $\kappa(y)$. This follows from
Varieties,
Lemma \ref{varieties-lemma-geometrically-connected-check-after-extension}.
\end{proof}

\begin{lemma}
\label{lemma-base-change-fibres-nr-geometrically-connected-components}
Let $f : X \to Y$ be a morphism of schemes. Let
$$
n_{X/Y} : Y \to \{0, 1, 2, 3, \ldots, \infty\}
$$
be the function which associates to $y \in Y$ the number of connected
components of $(X_y)_K$ where $K$ is a separably closed extension
of $\kappa(y)$. This is well defined and if $g : Y' \to Y$ is a morphism
then
$$
n_{X'/Y'} = n_{X/Y} \circ g
$$
where $X' \to Y'$ is the base change of $f$.
\end{lemma}

\begin{proof}
Suppose that $y' \in Y'$ has image $y \in Y$.
Suppose $K \supset \kappa(y)$ and $K' \supset \kappa(y')$ are separably
closed extensions. Then we may choose a commutative diagram
$$
\xymatrix{
K \ar[r] & K'' & K' \ar[l] \\
\kappa(y) \ar[u] \ar[rr] & & \kappa(y') \ar[u]
}
$$
of fields. The result follows as the morphisms of schemes
$$
\xymatrix{
(X'_{y'})_{K'} &
(X'_{y'})_{K''} = (X_y)_{K''} \ar[l] \ar[r] &
(X_y)_K
}
$$
induce bijections between connected components, see
Varieties,
Lemma \ref{varieties-lemma-separably-closed-field-connected-components}.
\end{proof}

\begin{lemma}
\label{lemma-geometrically-connected-generic-fibre}
Let $f : X \to Y$ be a morphism of schemes.
Assume
\begin{enumerate}
\item $Y$ is irreducible with generic point $\eta$,
\item $X_\eta$ is geometrically connected, and
\item $f$ is of finite type.
\end{enumerate}
Then there exists a nonempty open subscheme $V \subset Y$
such that $X_V \to V$ has geometrically connected fibres.
\end{lemma}

\begin{proof}
Choose a diagram
$$
\xymatrix{
X' \ar[d]_{f'} \ar[r]_{g'} & X_V \ar[r] \ar[d] & X \ar[d]^f \\
Y' \ar[r]^g & V \ar[r] & Y
}
$$
as in
Lemma \ref{lemma-make-components-generic-fibre-geometrically-irreducible}.
Note that the generic fibre of $f'$ is geometrically connected
(for example by
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}).
Suppose that the lemma holds for the morphism $f'$. This means that
there exists a nonempty open $W \subset Y'$ such that every fibre of
$X' \to Y'$ over $W$ is geometrically connected.
Then, as $g$ is an open morphism by
Morphisms, Lemma \ref{morphisms-lemma-etale-open}
all the fibres of $f$ at points of the nonempty open $V = g(W)$ are
geometrically connected, see
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}.
In this way we see that we may assume that the irreducible
components of the generic fibre $X_\eta$ are geometrically irreducible.

\medskip\noindent
Let $Y'$ be the reduction of $Y$, and set $X' = Y' \times_Y X$.
Then it suffices to prove the lemma for the morphism $X' \to Y'$
(for example by
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}
once again). Since the generic fibre of $X' \to Y'$ is the same as the
generic fibre of $X \to Y$ we see that we may assume that $Y$ is
irreducible and reduced (i.e., integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral})
and that the irreducible
components of the generic fibre $X_\eta$ are geometrically irreducible.

\medskip\noindent
At this point suppose that
$X_\eta = X_{1, \eta} \bigcup \ldots \bigcup X_{n, \eta}$
is the decomposition of the generic fibre into
(geometrically) irreducible components.
Let $X_i$ be the closure of $X_{i, \eta}$ in $X$.
After shrinking $Y$ we may assume that
$X = \bigcup X_i$, see
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
Let $Z_{i, j} = X_i \cap X_j$.
Let
$$
\{1, \ldots, n\} \times \{1, \ldots, n\} = I \amalg J
$$
where $(i, j) \in I$ if $Z_{i, j, \eta} = \emptyset$ and
$(i, j) \in J$ if $Z_{i, j, \eta} \not = \emptyset$.
After shrinking $Y$ we may assume that $Z_{i, j} = \emptyset$
for all $(i, j) \in I$, see
Lemma \ref{lemma-empty-generic-fibre}.
After shrinking $Y$ we obtain that $X_{i, y}$
is geometrically irreducible for each $i$ and all $y \in Y$, see
Lemma \ref{lemma-geom-irreducible-generic-fibre}.
After shrinking $Y$ some more we achieve the situation where
each $Z_{i, j} \to Y$ is flat and of finite presentation for
all $(i, j) \in J$, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}.
This means that $f(Z_{i, j}) \subset Y$ is open, see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open}.
We claim that
$$
V  = \bigcap\nolimits_{(i, j) \in J} f(Z_{i, j})
$$
works, i.e., that $X_y$ is geometrically connected for each
$y \in V$. Namely, the fact that $X_\eta$ is connected implies that
the equivalence relation generated by the pairs in $J$ has only
one equivalence class. Now if $y \in V$ and $K \supset \kappa(y)$
is a separably closed extension, then the irreducible components
of $(X_y)_K$ are the fibres $(X_{i, y})_K$. Moreover, we see by
construction and $y \in V$ that $(X_{i, y})_K$ meets $(X_{j, y})_K$
if and only if $(i, j) \in J$. Hence the remark on equivalence classes
shows that $(X_y)_K$ is connected and we win.
\end{proof}

\begin{lemma}
\label{lemma-nr-geom-connected-components-good}
Let $f : X \to Y$ be a morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ counting the numbers of geometrically
connected components of fibres of $f$ introduced in
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}.
Assume $f$ of finite type.
Let $y \in Y$ be a point. Then there exists a nonempty open
$V \subset \overline{\{y\}}$ such that $n_{X/Y}|_V$ is constant.
\end{lemma}

\begin{proof}
Let $Z$ be the reduced induced scheme structure on $\overline{\{y\}}$.
Let $f_Z : X_Z \to Z$ be the base change of $f$. Clearly it suffices to prove
the lemma for $f_Z$ and the generic point of $Z$. Hence we may assume that
$Y$ is an integral scheme, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
Our goal in this case is to produce a nonempty open $V \subset Y$ such that
$n_{X/Y}|_V$ is constant.

\medskip\noindent
We apply
Lemma \ref{lemma-make-components-generic-fibre-geometrically-irreducible}
to $f : X \to Y$ and we get $g : Y' \to V \subset Y$. As $g : Y' \to V$ is
surjective finite \'etale, in particular open (see
Morphisms, Lemma \ref{morphisms-lemma-etale-open}),
it suffices to prove that there exists an open $V' \subset Y'$
such that $n_{X'/Y'}|_{V'}$ is constant, see
Lemma \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}.
Thus we see that we may assume that all irreducible components of
the generic fibre $X_\eta$ are geometrically irreducible over $\kappa(\eta)$.
By
Varieties, Lemma
\ref{varieties-lemma-irreducible-components-geometrically-irreducible}
this implies that also the connected components of $X_\eta$ are
geometrically connected.

\medskip\noindent
At this point suppose that
$X_\eta = X_{1, \eta} \bigcup \ldots \bigcup X_{n, \eta}$
is the decomposition of the generic fibre into
(geometrically) connected components.
In particular $n_{X/Y}(\eta) = n$.
Let $X_i$ be the closure of
$X_{i, \eta}$ in $X$. After shrinking $Y$ we may assume that
$X = \bigcup X_i$, see
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
After shrinking $Y$ some more we see that each fibre of
$f$ has at least $n$ connected components, see
Lemma \ref{lemma-connected-components-in-neighbourhood}.
Hence $n_{X/Y}(y) \geq n$ for all $y \in Y$.
After shrinking $Y$ some more we obtain that $X_{i, y}$
is geometrically connected for each $i$ and all $y \in Y$, see
Lemma \ref{lemma-geometrically-connected-generic-fibre}.
Since $X_y = \bigcup X_{i, y}$
this shows that $n_{X/Y}(y) \leq n$ and finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-nr-geom-connected-components-constructible}
Let $f : X \to Y$ be a morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ counting the numbers of geometric
connected components of fibres of $f$ introduced in
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}.
Assume $f$ of finite presentation. Then the level sets
$$
E_n = \{y \in Y \mid n_{X/Y}(y) = n\}
$$
of $n_{X/Y}$ are locally constructible in $Y$.
\end{lemma}

\begin{proof}
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood
$V$ of $y$ in $Y$ such that $E_n \cap V$ is constructible in $V$. Thus we may
assume that $Y$ is affine. Write $Y = \Spec(A)$ and
$A = \colim A_i$ as a directed limit of finite type
$\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation whose base change to $Y$ recovers $f$. By
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}
it suffices to prove the lemma for $f_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
We will use the criterion of
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}
to prove that $E_n$ is constructible in case $Y$ is a Noetherian scheme.
To see this let $Z \subset Y$ be an irreducible closed subscheme.
We have to show that $E_n \cap Z$ either contains a nonempty open subset
or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then
Lemma \ref{lemma-nr-geom-connected-components-good}
shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$.
This clearly implies what we want.
\end{proof}

\begin{lemma}
\label{lemma-connected-flat-over-dvr}
\begin{slogan}
A flat degeneration of a disconnected scheme is either disconnected
or nonreduced.
\end{slogan}
Let $f : X \to S$ be a morphism of schemes.
Assume that
\begin{enumerate}
\item $S$ is the spectrum of a discrete valuation ring,
\item $f$ is flat,
\item $X$ is connected,
\item the closed fibre $X_s$ is reduced.
\end{enumerate}
Then the generic fibre $X_\eta$ is connected.
\end{lemma}

\begin{proof}
Write $S = \Spec(R)$ and let $\pi \in R$ be a uniformizer.
To get a contradiction assume that $X_\eta$ is disconnected.
This means there exists a nontrivial idempotent
$e \in \Gamma(X_\eta, \mathcal{O}_{X_\eta})$.
Let $U = \Spec(A)$ be any affine open in $X$.
Note that $\pi$ is a nonzerodivisor on $A$ as $A$ is flat over $R$, see
More on Algebra, Lemma \ref{more-algebra-lemma-flat-torsion-free}
for example. Then $e|_{U_\eta}$ corresponds to an element $e \in A[1/\pi]$.
Let $z \in A$ be an element such that $e = z/\pi^n$ with $n \geq 0$ minimal.
Note that $z^2 = \pi^nz$. This means that $z \bmod \pi A$ is nilpotent
if $n > 0$. By assumption $A/\pi A$ is reduced, and hence minimality of
$n$ implies $n = 0$. Thus we conclude that $e \in A$! In other words
$e \in \Gamma(X, \mathcal{O}_X)$. As $X$ is connected it follows
that $e$ is a trivial idempotent which is a contradiction.
\end{proof}







\section{Connected components meeting a section}
\label{section-connected-components}

\noindent
The results in this section are in particular applicable to a group scheme
$G \to S$ and its neutral section $e : S \to G$.

\begin{situation}
\label{situation-connected-along-section}
Here $f : X \to Y$ be a morphism of schemes, and
$s : Y \to X$ is a section of $f$.
For every $y \in Y$ we denote $X^0_y$ the connected component of $X_y$
containing $s(y)$. Finally, we set $X^0 = \bigcup_{y \in Y} X^0_y$.
\end{situation}

\begin{lemma}
\label{lemma-base-change-connected-along-section}
Let $f : X \to Y$, $s : Y \to X$ be as in
Situation \ref{situation-connected-along-section}.
If $g : Y' \to Y$ is any morphism, consider the base change diagram
$$
\xymatrix{
X' \ar[r]_{g'} \ar[d]^{f'} & X \ar[d]_f \\
Y' \ar@/^1pc/[u]^{s'} \ar[r]^g & Y \ar@/_1pc/[u]_s
}
$$
so that we obtain $(X')^0 \subset X'$.
Then $(X')^0 = (g')^{-1}(X^0)$.
\end{lemma}

\begin{proof}
Let $y' \in Y'$ with image $y \in Y$. We may think of
$X^0_y$ as a closed subscheme of $X_y$, see for example
Morphisms,
Definition \ref{morphisms-definition-scheme-structure-connected-component}.
As $s(y) \in X^0_y$ we conclude from
Varieties, Lemma
\ref{varieties-lemma-geometrically-connected-if-connected-and-point}
that $X_y^0$ is a geometrically connected scheme over $\kappa(y)$.
Hence $X_y^0 \times_y y' \to X'_{y'}$ is a connected closed subscheme
which contains $s'(y')$. Thus $X_y^0 \times_y y' \subset (X'_{y'})^0$.
The other inclusion $X_y^0 \times_y y' \supset (X'_{y'})^0$ is clear
as the image of $(X'_{y'})^0$ in $X_y$ is a connected subset of $X_y$ which
contains $s(y)$.
\end{proof}

\begin{lemma}
\label{lemma-connected-along-section-good}
Let $f : X \to Y$, $s : Y \to X$ be as in
Situation \ref{situation-connected-along-section}.
Assume $f$ of finite type. Let $y \in Y$ be a point.
Then there exists a nonempty open $V \subset \overline{\{y\}}$ such that
the inverse image of $X^0$ in the base change $X_V$ is open and closed in
$X_V$.
\end{lemma}

\begin{proof}
Let $Z \subset Y$ be the induced reduced closed subscheme
structure on $\overline{\{y\}}$. Let $f_Z : X_Z \to Z$ and $s_Z : Z \to X_Z$
be the base changes of $f$ and $s$. By
Lemma \ref{lemma-base-change-connected-along-section}
we have $(X_Z)^0 = (X^0)_Z$. Hence it suffices to prove the lemma for
the morphism $X_Z \to Z$ and the point $x \in X_Z$ which maps to the generic
point of $Z$. In other words we have reduced the problem to the case
where $Y$ is an integral scheme (see
Properties, Lemma \ref{properties-lemma-characterize-integral})
with generic point $\eta$. Our goal is to show that after shrinking
$Y$ the subset $X^0$ becomes an open and closed subset of $X$.

\medskip\noindent
Note that the scheme $X_\eta$ is of finite type over a field, hence Noetherian.
Thus its connected components are open as well as closed. Hence we may write
$X_\eta = X_\eta^0 \amalg T_\eta$ for some open and closed subset
$T_\eta$ of $X_\eta$. Next, let $T \subset X$ be the closure of $T_\eta$
and let $X^{00} \subset X$ be the closure of $X_\eta^0$. Note that
$T_\eta$, resp.\ $X^0_\eta$ is the generic fibre of $T$, resp.\ $X^{00}$,
see discussion preceding
Lemma \ref{lemma-cover-generic-fibre-neighbourhood}.
Moreover, that lemma implies that after shrinking $Y$ we may assume that
$X = X^{00} \cup T$ (set theoretically).
Note that $(T \cap X^{00})_\eta = T_\eta \cap X^0_\eta = \emptyset$.
Hence after shrinking $Y$ we may assume that $T \cap X^{00} = \emptyset$, see
Lemma \ref{lemma-empty-generic-fibre}.
In particular $X^{00}$ is open in $X$. Note that $X^0_\eta$ is connected
and has a rational point, namely $s(\eta)$, hence it is geometrically
connected, see
Varieties,
Lemma \ref{varieties-lemma-geometrically-connected-if-connected-and-point}.
Thus after shrinking $Y$ we may assume that all fibres of $X^{00} \to Y$
are geometrically connected, see
Lemma \ref{lemma-geometrically-connected-generic-fibre}.
At this point it follows that the fibres $X^{00}_y$ are
open, closed, and connected subsets of $X_y$ containing $\sigma(y)$.
It follows that $X^0 = X^{00}$ and we win.
\end{proof}

\begin{lemma}
\label{lemma-connected-along-section-locally-constructible}
Let $f : X \to Y$, $s : Y \to X$ be as in
Situation \ref{situation-connected-along-section}.
If $f$ is of finite presentation then $X^0$ is locally constructible
in $X$.
\end{lemma}

\begin{proof}
Let $x \in X$. We have to show that there exists an open neighbourhood
$U$ of $x$ such that $X^0 \cap U$ is constructible in $U$.
This reduces us to the case where $Y$ is affine.
Write $Y = \Spec(A)$ and $A = \colim A_i$ as a directed
limit of finite type $\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation, endowed with a section $s_i : \Spec(A_i) \to X_i$
whose base change to $Y$ recovers $f$ and the section $s$. By
Lemma \ref{lemma-base-change-connected-along-section}
it suffices to prove the lemma for $f_i, s_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
Assume $Y$ is a Noetherian affine scheme. Since $f$ is of finite presentation,
i.e., of finite type, we see that $X$ is a Noetherian scheme too, see
Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}.
In order to prove the lemma in
this case it suffices to show that for every irreducible closed subset
$Z \subset X$ the intersection $Z \cap X^0$ either contains a nonempty
open of $Z$ or is not dense in $Z$, see
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}.
Let $x \in Z$ be the generic point, and let $y = f(x)$. By
Lemma \ref{lemma-connected-along-section-good}
there exists a nonempty open subset $V \subset \overline{\{y\}}$ such
that $X^0 \cap X_V$ is open and closed in $X_V$. Since
$f(Z) \subset \overline{\{y\}}$ and $f(x) = y \in V$ we see that
$W = f^{-1}(V) \cap Z$ is a nonempty open subset of $Z$. It follows that
$X^0 \cap W$ is open and closed in $W$. Since $W$ is irreducible
we see that $X^0 \cap W$ is either empty or equal to $W$.
This proves the lemma.
\end{proof}

\begin{lemma}
\label{lemma-connected-along-section-open-neighbourhood}
Let $f : X \to Y$, $s : Y \to X$ be as in
Situation \ref{situation-connected-along-section}.
Let $y \in Y$ be a point.
Assume
\begin{enumerate}
\item $f$ is of finite presentation and flat, and
\item the fibre $X_y$ is geometrically reduced.
\end{enumerate}
Then $X^0$ is a neighbourhood of $X^0_y$ in $X$.
\end{lemma}

\begin{proof}
We may replace $Y$ with an affine open neighbourhood of $y$.
Write $Y = \Spec(A)$ and $A = \colim A_i$ as a directed
limit of finite type $\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation, endowed with a section $s_i : \Spec(A_i) \to X_i$
whose base change to $Y$ recovers $f$ and the section $s$.
After possibly increasing $i$ we may also assume that $f_i$ is flat, see
Limits, Lemma \ref{limits-lemma-descend-flat-finite-presentation}.
Let $y_i$ be the image of $y$ in $Y_i$. Note that
$X_y = (X_{i, y_i}) \times_{y_i} y$. Hence $X_{i, y_i}$ is geometrically
reduced, see
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-upstairs}.
By
Lemma \ref{lemma-base-change-connected-along-section}
it suffices to prove the lemma for the system $f_i, s_i, y_i \in Y_i$.
Thus we reduce to the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
Assume $Y$ is the spectrum of a Noetherian ring.
Since $f$ is of finite presentation,
i.e., of finite type, we see that $X$ is a Noetherian scheme too, see
Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}.
Let $x \in X^0$ be a point lying over $y$. By
Topology, Lemma \ref{topology-lemma-constructible-neighbourhood-Noetherian}
it suffices to prove that for any irreducible closed $Z \subset X$
passing through $x$ the intersection $X^0 \cap Z$ is dense in $Z$.
In particular it suffices to prove that the generic point $x' \in Z$
is in $X^0$. By
Properties, Lemma \ref{properties-lemma-locally-Noetherian-specialization-dvr}
we can find a discrete valuation ring $R$ and a morphism
$\Spec(R) \to X$ which maps the special point to $x$ and
the generic point to $x'$. We are going to think of $\Spec(R)$
as a scheme over $Y$ via the composition $\Spec(R) \to X \to Y$. By
Lemma \ref{lemma-base-change-connected-along-section}
we have that $(X_R)^0$ is the inverse image of $X^0$.
By construction we have a second section $t : \Spec(R) \to X_R$
(besides the base change $s_R$ of $s$)
of the structure morphism $X_R \to \Spec(R)$ such that
$t(\eta_R)$ is a point of $X_R$ which maps to $x'$ and
$t(0_R)$ is a point of $X_R$ which maps to $x$. Note that
$t(0_R)$ is in $(X_R)^0$ and that $t(\eta_R) \leadsto t(0_R)$.
Thus it suffices to prove that this implies that $t(\eta_R) \in (X_R)^0$.
Hence it suffices to prove the lemma in the case where $Y$
is the spectrum of a discrete valuation ring and $y$ its closed point.

\medskip\noindent
Assume $Y$ is the spectrum of a discrete valuation ring and $y$ is its closed
point. Our goal is to prove that $X^0$ is a neighbourhood of $X^0_y$.
Note that $X^0_y$ is open and closed in $X_y$ as $X_y$ has finitely
many irreducible components. Hence the complement $C = X_y \setminus X_y^0$
is closed in $X$. Thus $U = X \setminus C$ is an open neighbourhood of
$X^0_y$ and $U^0 = X^0$. Hence it suffices to prove the result for the
morphism $U \to Y$. In other words, we may assume that
$X_y$ is connected. Suppose that $X$ is disconnected, say
$X = X_1 \amalg \ldots \amalg X_n$ is a decomposition into connected
components. Then $s(Y)$ is completely contained in one of the $X_i$.
Say $s(Y) \subset X_1$. Then $X^0 \subset X_1$. Hence we may replace
$X$ by $X_1$ and assume that $X$ is connected. At this point
Lemma \ref{lemma-connected-flat-over-dvr}
implies that $X_\eta$ is connected, i.e., $X^0 = X$ and we win.
\end{proof}

\begin{lemma}
\label{lemma-connected-along-section-open}
Let $f : X \to Y$, $s : Y \to X$ be as in
Situation \ref{situation-connected-along-section}.
Assume
\begin{enumerate}
\item $f$ is of finite presentation and flat, and
\item all fibres of $f$ are geometrically reduced.
\end{enumerate}
Then $X^0$ is open in $X$.
\end{lemma}

\begin{proof}
This is an immediate consequence of
Lemma \ref{lemma-connected-along-section-open-neighbourhood}.
\end{proof}






\section{Dimension of fibres}
\label{section-dimension}

\begin{lemma}
\label{lemma-dimension-in-neighbourhood}
Let $f : X \to Y$ be a morphism of schemes. Assume $Y$ irreducible with
generic point $\eta$ and $f$ of finite type. If $X_\eta$ has dimension $n$,
then there exists a nonempty open $V \subset Y$
such that for all $y \in V$ the fibre $X_y$ has dimension $n$.
\end{lemma}

\begin{proof}
Let $Z = \{x \in X \mid \dim_x(X_{f(x)}) > n \}$. By
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}
this is a closed subset of $X$. By assumption $Z_\eta = \emptyset$.
Hence by
Lemma \ref{lemma-empty-generic-fibre}
we may shrink $Y$ and assume that $Z = \emptyset$. Let
$Z' = \{x \in X \mid \dim_x(X_{f(x)}) > n - 1 \} =
\{x \in X \mid \dim_x(X_{f(x)}) = n\}$. As before this is a closed subset
of $X$. By assumption we have $Z'_\eta \not = \emptyset$. Hence after
shrinking $Y$ we may assume that $Z' \to Y$ is surjective, see
Lemma \ref{lemma-nonempty-generic-fibre}.
Hence we win.
\end{proof}

\begin{lemma}
\label{lemma-base-change-dimension-fibres}
Let $f : X \to Y$ be a morphism of finite type. Let
$$
n_{X/Y} : Y \to \{0, 1, 2, 3, \ldots, \infty\}
$$
be the function which associates to $y \in Y$ the dimension of $X_y$.
If $g : Y' \to Y$ is a morphism then
$$
n_{X'/Y'} = n_{X/Y} \circ g
$$
where $X' \to Y'$ is the base change of $f$.
\end{lemma}

\begin{proof}
This follows from
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}.
\end{proof}

\begin{lemma}
\label{lemma-dimension-fibres-constructible}
Let $f : X \to Y$ be a morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ giving the dimension of fibres of $f$
introduced in
Lemma \ref{lemma-base-change-dimension-fibres}.
Assume $f$ of finite presentation. Then the level sets
$$
E_n = \{y \in Y \mid n_{X/Y}(y) = n\}
$$
of $n_{X/Y}$ are locally constructible in $Y$.
\end{lemma}

\begin{proof}
Fix $n$. Let $y \in Y$. We have to show that there exists an open neighbourhood
$V$ of $y$ in $Y$ such that $E_n \cap V$ is constructible in $V$. Thus we may
assume that $Y$ is affine. Write $Y = \Spec(A)$ and
$A = \colim A_i$ as a directed limit of finite type
$\mathbf{Z}$-algebras. By
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can find an $i$ and a morphism $f_i : X_i \to \Spec(A_i)$ of
finite presentation whose base change to $Y$ recovers $f$. By
Lemma \ref{lemma-base-change-dimension-fibres}
it suffices to prove the lemma for $f_i$. Thus we reduce to
the case where $Y$ is the spectrum of a Noetherian ring.

\medskip\noindent
We will use the criterion of
Topology, Lemma \ref{topology-lemma-characterize-constructible-Noetherian}
to prove that $E_n$ is constructible in case $Y$ is a Noetherian scheme.
To see this let $Z \subset Y$ be an irreducible closed subscheme.
We have to show that $E_n \cap Z$ either contains a nonempty open subset
or is not dense in $Z$. Let $\xi \in Z$ be the generic point. Then
Lemma \ref{lemma-dimension-in-neighbourhood}
shows that $n_{X/Y}$ is constant in a neighbourhood of $\xi$ in $Z$.
This implies what we want.
\end{proof}

\begin{lemma}
\label{lemma-dimension-fibres-flat}
Let $f : X \to Y$ be a flat morphism of schemes of finite presentation. Let
$n_{X/Y}$ be the function on $Y$ giving the dimension of fibres of $f$
introduced in Lemma \ref{lemma-base-change-dimension-fibres}.
Then $n_{X/Y}$ is lower semi-continuous.
\end{lemma}

\begin{proof}
Let $W \subset X$, $W = \coprod_{d \geq 0} U_d$ be the open constructed in
Lemmas \ref{lemma-flat-finite-presentation-CM-open} and
\ref{lemma-flat-finite-presentation-CM-pieces}.
Let $y \in Y$ be a point. If $n_{X/Y}(y) = \dim(X_y) = n$, then
$y$ is in the image of $U_n \to Y$.
By Morphisms, Lemma \ref{morphisms-lemma-fppf-open}
we see that $f(U_n)$ is open in $Y$.
Hence there is an open neighbourhoof of $y$ where
$n_{X/Y}$ is $\geq n$.
\end{proof}

\begin{lemma}
\label{lemma-dimension-fibres-proper}
Let $f : X \to Y$ be a proper morphism of schemes. Let
$n_{X/Y}$ be the function on $Y$ giving the dimension of fibres of $f$
introduced in Lemma \ref{lemma-base-change-dimension-fibres}.
Then $n_{X/Y}$ is upper semi-continuous.
\end{lemma}

\begin{proof}
Let $Z_d = \{x \in X \mid \dim_x(X_{f(x)}) > d\}$.
Then $Z_d$ is a closed subset of $X$ by
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}.
Since $f$ is proper $f(Z_d)$ is closed.
Since $y \in f(Z_d) \Leftrightarrow n_{X/Y}(y) > d$
we see that the lemma is true.
\end{proof}

\begin{lemma}
\label{lemma-dimension-fibres-proper-flat}
Let $f : X \to Y$ be a proper, flat morphism of schemes of finite presentation.
Let $n_{X/Y}$ be the function on $Y$ giving the dimension of fibres of $f$
introduced in Lemma \ref{lemma-base-change-dimension-fibres}.
Then $n_{X/Y}$ is locally constant.
\end{lemma}

\begin{proof}
Immediate consequence of
Lemmas \ref{lemma-dimension-fibres-flat} and
\ref{lemma-dimension-fibres-proper}.
\end{proof}

















\section{Weak relative Noether normalization}
\label{section-relative-noether-normalization}

\noindent
The goal of this section is to prove
Lemma \ref{lemma-weak-relative-noether-normalization}.

\begin{lemma}
\label{lemma-silly}
Let $R$ be a ring. Let $\mathfrak p_1, \ldots, \mathfrak p_r$
be prime ideals of $R$ with $\mathfrak p_i \not \subset \mathfrak p_j$
if $i \not = j$. Let $k_i \subset \kappa(\mathfrak p_i)$ be
subfields such that the extensions $\kappa(\mathfrak p_i)/k_i$
are not algebraic. Let $J \subset R$ be an ideal not contained
in any of the $\mathfrak p_i$. Then there exists an element $x \in J$
such that the image of $x$ in $\kappa(\mathfrak p_i)$
is transcendental over $k_i$ for $i = 1, \ldots, r$.
\end{lemma}

\begin{proof}
The ideal
$J_i = J \mathfrak p_1 \ldots \hat{\mathfrak p}_i \ldots \mathfrak p_r$ is not
contained in $\mathfrak p_i$, see
Algebra, Lemma \ref{algebra-lemma-product-ideals-in-prime}.
It follows that every element $\xi$ of
$\kappa(\mathfrak p_i) = \text{Frac}(B/\mathfrak p_i)$
is of the form $\xi = a/b$ with $a, b \in J_i$
and $b \not \in \mathfrak p_i$. Choosing $\xi$ transcendental
over $k_i$ we see that either $a$ or $b$ maps to an element
of $\kappa(\mathfrak p_i)$ transcendental over $k_i$.
We conclude that for every $i = 1, \ldots, r$
we can find an element
$x_i \in J_i = J \mathfrak p_1 \ldots \hat{\mathfrak p}_i \ldots \mathfrak p_r$
which maps to an element of $\kappa(\mathfrak p_i)$
transcendental over $k_i$. Then $x = x_1 + \ldots + x_r$ works.
\end{proof}

\begin{lemma}
\label{lemma-sum-is-ok}
Let $R \to S$ be a finite type ring map. Let $d \geq 0$. Let $a, b \in S$.
Assume that the fibres of
$$
f_a : \Spec(S) \longrightarrow \mathbf{A}^1_R
$$
given by the $R$-algebra map $R[x] \to S$ sending $x$ to $a$
have dimension $\leq d$. Then there exists an $n_0$ such that for
$n \geq n_0$ the fibres of
$$
f_{a^n + b} : \Spec(S) \longrightarrow \mathbf{A}^1_R
$$
given by the $R$-algebra map $R[x] \to S$ sending $x$ to $a^n + b$
have dimension $\leq d$.
\end{lemma}

\begin{proof}
In this paragraph we reduce to the case where $R \to S$ is of finite
presentation. Namely, write $S = R[A, B, x_1, \ldots, x_n]/J$ for some ideal
$J \subset R[x_1, \ldots, x_n]$ where $A$ and $B$ map to $a$ and $b$ in $S$.
Then $J$ is the union of its finitely generated ideals $J_\lambda \subset J$.
Set $S_\lambda = R[A, B, x_1, \ldots, x_n]/J_\lambda$ and
denote $a_\lambda, b_\lambda \in S_\lambda$ the images of $A$ and $B$.
Then for some $\lambda$ the fibres of
$$
f_{a_\lambda} : \Spec(S_\lambda) \longrightarrow \mathbf{A}^1_R
$$
have dimension $\leq d$, see Limits, Lemma \ref{limits-lemma-limit-dimension}.
Fix such a $\lambda$. If we can find $n_0$ which works for $R \to S_\lambda$,
$a_\lambda$, $b_\lambda$, then $n_0$ works for $R \to S$. Namely, the fibres
of $f_{a_\lambda^n + b_\lambda} : \Spec(S_\lambda) \to \mathbf{A}^1_R$
contain the fibres of $f_{a^n + b} : \Spec(S) \to \mathbf{A}^1_R$.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $R \to S$ is of finite presentation. In this paragraph we reduce
to the case where $R$ is of finite type over $\mathbf{Z}$. By
Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}
we can find a directed set $\Lambda$ and a system of ring maps
$R_\lambda \to S_\lambda$ over $\Lambda$ whose colimit is
$R \to S$ such that $S_\mu = S_\lambda \otimes_{R_\lambda} R_\mu$
for $\mu \geq \lambda$ and such that each $R_\lambda$ and $S_\lambda$
is of finite type over $\mathbf{Z}$. Choose $\lambda_0 \in \Lambda$ and
elements $a_{\lambda_0}, b_{\lambda_0} \in S_{\lambda_0}$ mapping to
$a, b \in S$. For $\lambda \geq \lambda_0$ denote
$a_\lambda, b_\lambda \in S_\lambda$
the image of $a_{\lambda_0}, b_{\lambda_0}$.
Then for $\lambda \geq \lambda_0$ large enough the fibres of
$$
f_{a_\lambda} : 
\Spec(S_\lambda) \longrightarrow \mathbf{A}^1_{R_\lambda}
$$
have dimension $\leq d$, see
Limits, Lemma \ref{limits-lemma-descend-dimension-d}.
Fix such a $\lambda$. If we can find $n_0$ which works for
$R_\lambda \to S_\lambda$, $a_\lambda$, $b_\lambda$, then $n_0$
works for $R \to S$. Namely, any fibre of
$f_{a^n + b} : \Spec(S) \to \mathbf{A}^1_R$
has the same dimension as a fibre of
$f_{a_\lambda^n + b_\lambda} : \Spec(S_\lambda) \to \mathbf{A}^1_{R_\lambda}$
by Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}.
This reduces us the the case discussed in the next paragraph.

\medskip\noindent
Assume $R$ and $S$ are of finite type over $\mathbf{Z}$. In particular
the dimension of $R$ is finite, and we may use induction on $\dim(R)$.
Thus we may assume the result holds for all situations with
$R' \to S'$, $a$, $b$ as in the lemma with $R'$ and $S'$ of finite type
over $\mathbf{Z}$ but with $\dim(R') < \dim(R)$.

\medskip\noindent
Since the statement is about the topology of the spectrum of $S$
we may assume $S$ is reduced. Let $S^\nu$ be the normalization of $S$.
Then $S \subset S^\nu$ is a finite extension as $S$ is excellent, see
Algebra, Proposition \ref{algebra-proposition-ubiquity-nagata}
and Morphisms, Lemma \ref{morphisms-lemma-nagata-normalization}.
Thus $\Spec(S^\nu) \to \Spec(S)$ is surjective and finite
(Algebra, Lemma \ref{algebra-lemma-integral-overring-surjective}).
It follows that if the result holds for $R \to S^\nu$ and the
images of $a$, $b$ in $S^\nu$, then the result holds for $R \to S$, $a$, $b$.
(Small detail omitted.) This reduces us to the case discussed in the
next paragraph.

\medskip\noindent
Assume $R$ and $S$ are of finite type over $\mathbf{Z}$ and
$S$ normal. Then $S = S_1 \times \ldots \times S_r$ for some
normal domains $S_i$. If the result holds for each $R \to S_i$
and the images of $a$, $b$ in $S_i$, then the result holds for
$R \to S$, $a$, $b$. (Small detail omitted.)
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $R$ and $S$ are of finite type over $\mathbf{Z}$ and
$S$ a normal domain. We may replace $R$ by the image of $R$ in $S$
(this does not increase the dimension of $R$).
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $R \subset S$ are of finite type over $\mathbf{Z}$ and
$S$ a normal domain. Consider the morphism
$$
f_a : \Spec(S) \to \mathbf{A}^1_R
$$
The assumption tells us that $f_a$ has fibres of dimension $\leq d$.
Hence the fibres of $f : \Spec(S) \to \Spec(R)$ have dimension $\leq d + 1$
(Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point-additive}).
Consider the morphism of integral schemes
$$
\phi : \Spec(S) \to \mathbf{A}^2_R = \Spec(R[x, y])
$$
corresponding to the $R$-algebra map $R[x, y] \to S$ sending $x$ to $a$
and $y$ to $b$. There are two cases to consider
\begin{enumerate}
\item $\phi$ is dominant, and
\item $\phi$ is not dominant.
\end{enumerate}
We claim that in both cases there exists an integer $n_0$
and a nonempty open $V \subset \Spec(R)$ such that for $n \geq n_0$
the fibres of $f_{a^n + b}$ at points $q \in \mathbf{A}^1_V$
have dimension $\leq d$.

\medskip\noindent
Proof of the claim in case (1). We have $f_{a^n + b} = \pi_n \circ \phi$
where
$$
\pi_n :  \mathbf{A}^2_R \to \mathbf{A}^1_R
$$
is the flat morphism corresponding to the $R$-algebra map $R[x] \to R[x, y]$
sending $x$ to $x^n + y$. Since $\phi$ is dominant there is a dense open
$U \subset \Spec(S)$ such that $\phi|_U : U \to \mathbf{A}^2_R$ is flat
(this follows for example from generic flatness, see
Morphisms, Proposition \ref{morphisms-proposition-generic-flatness}).
Then the composition
$$
f_{a^n + b}|_U :
U \xrightarrow{\phi|_U}
\mathbf{A}^2_R
\xrightarrow{\pi_n}
\mathbf{A}^1_R
$$
is flat as well. Hence the fibres of this morphism have at least
codimension $1$ in the fibres of $f|_U : U \to \Spec(R)$ by
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point-additive}.
In other words, the fibres of $f_{a^n + b}|_U$ have dimension $\leq d$.
On the other hand, since $U$ is dense in $\Spec(S)$, we can find a nonempty
open $V \subset \Spec(R)$ such that $U \cap f^{-1}(p) \subset f^{-1}(p)$
is dense for all $p \in V$ (see for example Lemma
\ref{lemma-nowhere-dense-generic-fibre}).
Thus $\dim(f^{-1}(p) \setminus U \cap f^{-1}(p)) \leq d$ and
we conclude that our claim is true (as any fibres of
$f_{a^n + b} : \Spec(S) \to \mathbf{A}^1_R$
is contained in a fibre of $f$).

\medskip\noindent
Case (2). In this case we can find a nonzero $g = \sum c_{ij} x^i y^j$
in $R[x, y]$ such that $\Im(\phi) \subset V(g)$. In fact, we may assume
$g$ is irreducible over $\text{Frac}(R)$. If $g \in R[x]$, say with leading
coefficient $c$, then over $V = D(c) \subset \Spec(R)$ the fibres of
$f$ already have dimension $\leq d$ (because the image of $f_a$ is contained
in $V(g) \subset \mathbf{A}^1_R$ which has finite fibres over $V$). Hence
we may assume $g$ is not contained in $R[x]$.
Let $s \geq 1$ be the degree of $g$ as a polynomial in $y$ and
let $t$ be the degree of $\sum c_{is} x^i$ as a polynomial in $x$.
Then $c_{ts}$ is nonzero and
$$
g(x, -x^n) = (-1)^s c_{ts} x^{t + sn} + l.o.t.
$$
provided that $n$ is bigger than the degree of $g$ as a polynomial in $x$
(small detail omitted). For such $n$ the polynomial $g(x, -x^n)$ 
is a nonzero polynomial in $x$ and maps to a nonzero polynomial in
$\kappa(\mathfrak p)[x]$ for all $\mathfrak p \subset R$,
$c_{st} \not \in \mathfrak p$. We conclude that our claim is
true for $V$ equal to the principal open $D(c_{ts})$ of $\Spec(R)$.

\medskip\noindent
OK, and now we can use induction on $\dim(R)$. Namely, let
$I \subset R$ be an ideal such that $V(I) = \Spec(R) \setminus V$.
Observe that $\dim(R/I) < \dim(R)$ as $R$ is a domain.
Let $n'_0$ be the integer we have by induction on $\dim(R)$
for $R/I \to S/IS$ and the images of $a$ and $b$ in $S/IS$.
Then $\max(n_0, n'_0)$ works.
\end{proof}

\begin{lemma}
\label{lemma-weak-relative-noether-normalization}
Let $R \to S$ be a finite type ring map. Let $d$ be the maximum
of the dimensions of fibres of $\Spec(S) \to \Spec(R)$.
Then there exists a quasi-finite ring map
$R[t_1, \ldots, t_d] \to S$.
\end{lemma}

\begin{proof}
In this paragraph we reduce to the case where $R \to S$ is of finite
presentation. Namely, write $S = R[x_1, \ldots, x_n]/J$ for some ideal
$J \subset R[x_1, \ldots, x_n]$.
Then $J$ is the union of its finitely generated ideals $J_\lambda \subset J$.
Set $S_\lambda = R[x_1, \ldots, x_n]/J_\lambda$.
Then for some $\lambda$ the fibres of
$\Spec(S_\lambda) \to \Spec(R)$
have dimension $\leq d$, see Limits, Lemma \ref{limits-lemma-limit-dimension}.
Fix such a $\lambda$. If we can find a quasi-finite
$R[t_1, \ldots, t_d] \to S_\lambda$, then of course the composition
$R[t_1, \ldots, t_d] \to S$ is quasi-finite.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $R \to S$ is of finite presentation. In this paragraph we reduce
to the case where $R$ is of finite type over $\mathbf{Z}$. By
Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}
we can find a directed set $\Lambda$ and a system of ring maps
$R_\lambda \to S_\lambda$ over $\Lambda$ whose colimit is
$R \to S$ such that $S_\mu = S_\lambda \otimes_{R_\lambda} R_\mu$
for $\mu \geq \lambda$ and
such that each $R_\lambda$ and $S_\lambda$ is of finite
type over $\mathbf{Z}$.
Then for $\lambda$ large enough the fibres of
$\Spec(S_\lambda) \to \Spec(R_\lambda)$
have dimension $\leq d$, see
Limits, Lemma \ref{limits-lemma-descend-dimension-d}.
Fix such a $\lambda$. If we can find a quasi-finite ring map
$R_\lambda[t_1, \ldots, t_d] \to S_\lambda$, then the base change
$R[t_1, \ldots, t_d] \to S$ is quasi-finite too
(Algebra, Lemma \ref{algebra-lemma-quasi-finite-base-change}).
This reduces us the the case discussed in the next paragraph.

\medskip\noindent
Assume $R$ and $S$ are of finite type over $\mathbf{Z}$. If $d = 0$, then
the ring map is quasi-finite and we are done. Assume $d > 0$.
We will find an element $a \in S$ such that
the fibres of the $R$-algebra map $R[x] \to S$, $x \mapsto a$
have dimension $< d$. This will finish the proof by induction.

\medskip\noindent
We will prove the existence of $a$ by induction on $\dim(R)$.

\medskip\noindent
Let $\mathfrak q_1, \ldots, \mathfrak q_r \subset S$ be those
among the minimal primes of $S$ such that $\dim_{\mathfrak q_i}(S/R) = d$.
For notation, see
Algebra, Definition \ref{algebra-definition-relative-dimension}.
Say $\mathfrak q_i$ lies over the prime $\mathfrak p_i \subset R$.
We have $\text{trdeg}_{\kappa(\mathfrak p_i)}(\kappa(\mathfrak q_i)) = d$
as $\mathfrak q_i$ is a generic point of its fibre; for example
apply Algebra, Lemma \ref{algebra-lemma-dimension-at-a-point-finite-type-field}
to $S \otimes_R \kappa(\mathfrak p_i)$.
Hence by Lemma \ref{lemma-silly} we can find an element $a \in S$ such that
the image of $a$ in $\kappa(\mathfrak q_i)$ is transcendental over
$\kappa(\mathfrak p_i)$ for $i = 1, \ldots, r$.
Consider the morphism
$$
f_a : \Spec(S) \longrightarrow \mathbf{A}^1_R
$$
corresponding the $R$-algebra homomorphism $R[x] \to S$
to mapping $x$ to $a$. Let $U \subset \Spec(S)$ be the open
subset where the fibres have dimension $\leq d - 1$, see
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}.
By construction $U$ contains all the generic points of $\Spec(S)$.
In particular we see that $U$ contains all generic points of
all the generic fibres of $\Spec(S) \to \Spec(R)$ as such points are
necessarily generic points of $\Spec(S)$. Set $T = \Spec(S) \setminus U$
viewed as a reduced closed subscheme of $\Spec(S)$.
It follows from what we just said and the assumption that
$\dim(S/R) \leq d$ that
the generic fibres of $T \to \Spec(R)$ have dimension $\leq d - 1$.
Hence by Lemma \ref{lemma-dimension-in-neighbourhood},
applied several times to produce open neighbourhoods of the generic
points of $\Spec(R)$, we can find a dense open $V \subset \Spec(R)$ such that
$T_V \to V$ has fibres of dimension $\leq d - 1$.
We conclude that for $q \in \mathbf{A}^1_V$ the fibre of
$f_a$ over $q$ has dimension $\leq d - 1$ (as we have bounded the dimension
of the fibre of $f_a|_U$ and of the fibre of $f_a|_T$).

\medskip\noindent
By prime avoidance, we may assume that $V = D(f)$ for some $f \in R$.
Then we see that the ring map $R_f[x] \to S_f$, $x \mapsto a$
has fibres of dimension $\leq d - 1$.
We may replace $a$ by $fa$ and assume $a \in (f)$.
By induction on $\dim(R)$ we can find an element
$\overline{b} \in S/fS$
such that the fibres of $\Spec(S/fS) \to \Spec(R/fR[x])$,
$x \mapsto \overline{b}$ have dimension $\leq d - 1$.
Let $b \in S$ be a lift of $\overline{b}$.
By Lemma \ref{lemma-sum-is-ok} there exists an $n > 0$ such
that $a^n + b$ still works for $R_f \to S_f$.
On the other hand, the image of $a^n + b$ in $S/fS$ is $\overline{b}$
and the proof is complete.
\end{proof}













\section{Bertini theorems}
\label{section-bertini}

\noindent
We continue the discussion started in
Varieties, Section \ref{varieties-section-bertini}.
In this section we prove that general hyperplane sections
of geometrically irreducible varieties are geometrically irreducible
following the remarkable argument given in \cite{Jou}.

\begin{lemma}
\label{lemma-amazing-bertini-lemma}
\begin{reference}
See pages 71 and 72 of \cite{Jou}
\end{reference}
Let $K/k$ be a geometrically irreducible and finitely generated
field extension. Let $n \geq 1$.
Let $g_1, \ldots, g_n \in K$ be elements such that there
exist $c_1, \ldots, c_n \in k$ such that the elements
$$
x_1, \ldots, x_n, \sum g_ix_i, \sum c_ig_i \in K(x_1, \ldots, x_n)
$$
are algebraically independent over $k$. Then
$K(x_1, \ldots, x_n)$ is geometrically irreducible over
$k(x_1, \ldots, x_n, \sum g_ix_i)$.
\end{lemma}

\begin{proof}
Let $c_1, \ldots, c_n \in k$ be as in the statement of the lemma.
Write $\xi = \sum g_ix_i$ and $\delta = \sum c_ig_i$.
For $a \in k$ consider the automorphism $\sigma_a$
of $K(x_1, \ldots, x_n)$ given by the identity on $K$ and the rules
$$
\sigma_a(x_i) = x_i + a c_i
$$
Observe that $\sigma_a(\xi) = \xi + a \delta$ and $\sigma_a(\delta) = \delta$.
Consider the tower of fields
$$
K_0 = k(x_1, \ldots, x_n) \subset
K_1 = K_0(\xi) \subset
K_2 = K_0(\xi, \delta) \subset K(x_1, \ldots, x_n) = \Omega
$$
Observe that $\sigma_a(K_0) = K_0$ and $\sigma_a(K_2) = K_2$.
Let $\theta \in \Omega$ be separable algebraic over $K_1$.
We have to show $\theta \in K_1$, see Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-separable-elements}.

\medskip\noindent
Denote $K'_2$ the separable algebraic closure of $K_2$ in $\Omega$.
Since $K'_2/K_2$ is finite (Algebra, Lemma
\ref{algebra-lemma-make-geometrically-irreducible}) and
separable there are only a finite number of fields in
between $K'_2$ and $K_2$ (Fields, Lemma \ref{fields-lemma-primitive-element}).
If $k$ is infinite\footnote{We will deal with the finite field case in the
last paragraph of the proof.}, then we can find distinct elements
$a_1, a_2$ of $k$ such that
$$
K_2(\sigma_{a_1}(\theta)) = K_2(\sigma_{a_2}(\theta))
$$
as subfields of $\Omega$. Write $\theta_i = \sigma_{a_i}(\theta)$
and $\xi_i = \sigma_{a_i}(\xi) = \xi + a_i \delta$. Observe that
$$
K_2 = K_0(\xi_1, \xi_2)
$$
as we have $\xi_i = \xi + a_i \delta$,
$\xi = (a_2 \xi_1 - a_1 \xi_2)/(a_2 - a_1)$, and
$\delta = (\xi_1 - \xi_2)/(a_1 - a_2)$.
Since $K_2/K_0$ is purely transcendental of degree $2$ we conclude
that $\xi_1$ and $\xi_2$ are algebraically indepedent over $K_0$.
Since $\theta_1$ is algebraic over $K_0(\xi_1)$ we conclude that
$\xi_2$ is transcendental over $K_0(\xi_1, \theta_1)$.

\medskip\noindent
By assumption $K/k$ is geometrically irreducible. This implies
that $K(x_1, \ldots, x_n)/K_0$ is geometrically irreducible
(Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-base-change-transcendental}).
This in turn implies that $K_0(\xi_1, \theta_1)/K_0$
is geometrically irreducible as a subextension
(Algebra, Lemma \ref{algebra-lemma-subalgebra-geometrically-irreducible}).
Since $\xi_2$ is transcendental over $K_0(\xi_1, \theta_1)$
we conclude that $K_0(\xi_1, \xi_2, \theta_1)/K_0(\xi_2)$
is geometrically irreducible (Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-add-transcendental}).
By our choice of $a_1, a_2$ above we have
$$
K_0(\xi_1, \xi_2, \theta_1) =
K_2(\sigma_{a_1}(\theta)) =
K_2(\sigma_{a_2}(\theta)) =
K_0(\xi_1, \xi_2, \theta_2)
$$
Since $\theta_2$ is separably algebraic over $K_0(\xi_2)$
we conclude by Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-separable-elements} again that
$\theta_2 \in K_0(\xi_2)$. Taking $\sigma_{a_2}^{-1}$
of this relation givens $\theta \in K_0(\xi) = K_1$ as desired.

\medskip\noindent
This finishes the proof in case $k$ is infinite. If $k$ is finite,
then we can choose a variable $t$ and consider the extension
$K(t)/k(t)$ which is geometrically irreducible by
Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-base-change-transcendental}.
Since it is still be true that
$x_1, \ldots, x_n, \sum g_ix_i, \sum c_ig_i$
in $K(t, x_1, \ldots, x_n)$ are algebraically independent over $k(t)$
we conclude that $K(t, x_1, \ldots, x_n)$
is geometrically irreducible over
$k(t, x_1, \ldots, x_n, \sum g_ix_i)$
by the argument already given.
Then using Algebra, Lemma
\ref{algebra-lemma-geometrically-irreducible-base-change-transcendental}
once more finishes the job.
\end{proof}

\begin{lemma}
\label{lemma-algebraically-independent}
Let $A$ be a domain of finite type over a field $k$. Let $n \geq 2$.
Let $g_1, \ldots, g_n \in A$ be elements such that $V(g_1, g_2)$
has an irreducible component of dimension $\dim(A) - 2$.
Then there exist $c_1, \ldots, c_n \in k$ such that the elements
$$
x_1, \ldots, x_n, \sum g_ix_i, \sum c_ig_i \in
\text{Frac}(A)(x_1, \ldots, x_n)
$$
are algebraically independent over $k$.
\end{lemma}

\begin{proof}
The algebraic independence over $k$ means that the morphism
$$
T = \Spec(A[x_1, \ldots, x_n])
\longrightarrow
\Spec(k[x_1, \ldots, x_n, y, z]) = S
$$
given by $y = \sum g_ix_i$ and $z = \sum c_ig_i$ is dominant.
Set $d = \dim(A)$. If $T \to S$ is not dominant, then the image
has dimension $< n + 2$ and hence every irreducible component
of every fibre has dimension $> d + n - (n + 2) = d - 2$, see
Varieties, Lemma
\ref{varieties-lemma-dimension-fibres-locally-algebraic}.
Choose a closed point $u \in V(g_1, g_2)$ contained in an irreducible component
of dimension $d - 2$ and in no other component of $V(g_1, g_2)$.
Consider the closed point $t = (u, 1, 0, \ldots 0)$
of $T$ lying over $u$. Set $(c_1, \ldots, c_n) = (0, 1, 0, \ldots, 0)$.
Then $t$ maps to the point $s = (1, 0, \ldots, 0)$ of $S$.
The fibre of $T \to S$ over $s$ is cut out by
$$
x_1 - 1, x_2, \ldots, x_n, \sum x_ig_i, g_2
$$
and hence equivalently is cut out by
$$
x_1 - 1, x_2, \ldots, x_n, g_1, g_2
$$
By our condition on $g_1, g_2$ this subscheme has an irreducible component
of dimension $d - 2$.
\end{proof}

\begin{lemma}
\label{lemma-bertini-irreducible}
\begin{reference}
\cite[Theorem 6.3 part 4)]{Jou}
\end{reference}
In Varieties, Situation \ref{varieties-situation-family-divisors} assume
\begin{enumerate}
\item $X$ is of finite type over $k$,
\item $X$ is geometrically irreducible over $k$,
\item there exist $v_1, v_2, v_3 \in V$ and an irreducible component
$Z$ of $H_{v_2} \cap H_{v_3}$ such that $Z \not \subset H_{v_1}$ and
$\text{codim}(Z, X) = 2$, and
\item every irreducible component $Y$ of $\bigcap_{v \in V} H_v$
has $\text{codim}(Y, X) \geq 2$.
\end{enumerate}
Then for general $v \in V \otimes_k k'$
the scheme $H_v$ is geometrically irreducible over $k'$.
\end{lemma}

\begin{proof}
In order for assumption (3) to hold, the elements $v_1, v_2, v_3$
must be $k$-linearly independent in $V$ (small detail omitted).
Thus we may choose a basis $v_1, \ldots, v_r$ of $V$ incorporating
these elements as the first $3$. Recall that
$H_{univ} \subset \mathbf{A}^r_k \times_k X$ is the ``universal divisor''.
Consider the projection $q : H_{univ} \to \mathbf{A}^r_k$
whose scheme theoretic fibres are the divisors $H_v$. By
Lemma \ref{lemma-geom-irreducible-generic-fibre}
it suffices to show that the generic fibre of $q$ is geometrically
irreducible.
To prove this we may replace $X$ by its reduction, hence
we may assume $X$ is an integral scheme of finite type over $k$.

\medskip\noindent
Let $U \subset X$ be a nonempty affine open such that
$\mathcal{L}|_U \cong \mathcal{O}_U$. Write $U = \Spec(A)$.
Denote $f_i \in A$ the element corresponding to section $\psi(v_i)|_U$
via the isomorphism $\mathcal{L}|_U \cong \mathcal{O}_U$.
Then $H_{univ} \cap (\mathbf{A}^r_k \times_k U)$ is given by
$$
H_U = \Spec(A[x_1, \ldots, x_r]/(x_1f_1 + \ldots + x_rf_r))
$$
By our choice of basis we see that $f_1$ cannot be zero because this
would mean $v_1 = 0$ and hence $H_{v_1} = X$ which contradicts
assumption (3). Hence $\sum x_if_i$ is a nonzerodivisor in
$A[x_1, \ldots, x_r]$.
It follows that every irreducible component of $H_U$ has dimension
$d + r - 1$ where $d = \dim(X) = \dim(A)$. If $U' = U \cap D(f_1)$
then we see that
$$
H_{U'} =
\Spec(A_{f_1}[x_1, \ldots, x_r]/(x_1f_1 + \ldots + x_rf_r)) \cong
\Spec(A_{f_1}[x_2, \ldots x_r]) =
\mathbf{A}^{r - 1}_k \times_k U'
$$
is irreducible. On the other hand, we have
$$
H_U \setminus H_{U'} =
\Spec(A/(f_1)[x_1, \ldots, x_r]/(x_2f_2 + \ldots + x_rf_r))
$$
which has dimension at most $d + r - 2$. Namely, for $i \not = 1$
the scheme $(H_U \setminus H_{U'}) \times_U D(f_i)$ is either empty
(if $f_i = 0$) or by the same argument as above isomorphic to an $r - 1$
dimensional affine space over an open of $\Spec(A/(f_1))$ and hence has
dimension at most $d + r - 2$.
On the other hand, $(H_U \setminus H_{U'}) \times_U V(f_2, \ldots, f_r)$
is an $r$ dimensional affine space over $\Spec(A/(f_1, \ldots, f_r))$
and hence assumption (4) tells us this has dimension at most
$d + r - 2$. We conclude that $H_U$ is irreducible for every $U$ as above.
It follows that $H_{univ}$ is irreducible.

\medskip\noindent
Thus it suffices to show that the generic point of $H_{univ}$
is geometrically irreducible over the generic point of $\mathbf{A}^r_k$, see
Varieties, Lemma
\ref{varieties-lemma-geometrically-irreducible-function-field}.
Choose a nonempty affine open $U = \Spec(A)$ of $X$
contained in $X \setminus H_{v_1}$ which meets the irreducible
component $Z$ of $H_{v_2} \cap H_{v_3}$ whose existence is asserted in
assumption (3). With notation as above we have to prove that
the field extension
$$
\text{Frac}(A[x_1, \ldots, x_r]/(x_1f_1 + \ldots + x_rf_r))/
k(x_1, \ldots , x_r)
$$
is geometrically irreducible. Observe that $f_1$ is invertible in $A$
by our choice of $U$.
Set $K = \text{Frac}(A)$ equal to the fraction field of $A$.
Eliminating the variable $x_1$ as above,
we find that we have to show that the field extension
$$
K(x_2, \ldots, x_r)/
k(x_2, \ldots, x_r, -\sum\nolimits_{i = 2, \ldots, r} f_1^{-1}f_i x_i)
$$
is geometrically irreducible. By Lemma \ref{lemma-amazing-bertini-lemma}
it suffices to show that for some $c_2, \ldots, c_r \in k$ the elements
$$
x_2, \ldots, x_r, \sum\nolimits_{i = 2, \ldots, r} f_1^{-1}f_i x_i,
\sum\nolimits_{i = 2, \ldots, r} c_if_1^{-1}f_i
$$
are algebraically independent over $k$ in the fraction field of
$A[x_2, \ldots, x_r]$. This follows from
Lemma \ref{lemma-algebraically-independent}
and the fact that $Z \cap U$ is an irreducible
component of $V(f_1^{-1}f_2, f_1^{-1}f_3) \subset U$.
\end{proof}

\begin{remark}
\label{remark-geometric-proof-bertini-irreducible}
Let us sketch a ``geometric'' proof of a special case of
Lemma \ref{lemma-bertini-irreducible}. Namely, say $k$
is an algebraically closed field and $X \subset \mathbf{P}^n_k$ is smooth and
irreducible of dimension $\geq 2$. Then we claim there is a
hyperplane $H \subset \mathbf{P}^n_k$ such that $X \cap H$ is
smooth and irreducible. Namely, by
Varieties, Lemma \ref{varieties-lemma-bertini}
for a general $v \in V = kT_0 \oplus \ldots \oplus kT_n$
the corresponding hyperplane section $X \cap H_v$ is smooth.
On the other hand, by Enriques-Severi-Zariski the scheme
$X \cap H_v$ is connected, see
Varieties, Lemma \ref{varieties-lemma-connectedness-ample-divisor}.
Hence $X \cap H_v$ is smooth and irreducible.
\end{remark}













\section{Theorem of the cube}
\label{section-theorem-cube}

\noindent
The following lemma tells us that the diagonal of the Picard
functor is representable by locally closed immersions under
the assumptions made in the lemma.

\begin{lemma}
\label{lemma-diagonal-picard-flat-proper}
Let $f : X \to S$ be a flat, proper morphism of finite presentation.
Let $\mathcal{E}$ be a finite locally free $\mathcal{O}_X$-module.
For a morphism $g : T \to S$ consider the base change diagram
$$
\xymatrix{
X_T \ar[d]_p \ar[r]_q & X \ar[d]^f \\
T \ar[r]^g & S
}
$$
Assume $\mathcal{O}_T \to p_*\mathcal{O}_{X_T}$ is an
isomorphism for all $g : T \to S$. Then there exists an
immersion $j : Z \to S$ of finite presentation such that
a morphism $g : T \to S$ factors through $Z$ if and only if
there exists a finite locally free $\mathcal{O}_T$-module $\mathcal{N}$
with $p^*\mathcal{N} \cong q^*\mathcal{E}$.
\end{lemma}

\begin{proof}
Observe that the fibres $X_s$ of $f$ are connected by our assumption
that $H^0(X_s, \mathcal{O}_{X_s}) = \kappa(s)$. Thus the rank of
$\mathcal{E}$ is constant on the fibres. Since $f$ is open
(Morphisms, Lemma \ref{morphisms-lemma-fppf-open}) and closed
we conclude that there is a decomposition $S = \coprod S_r$
of $S$ into open and closed subschemes such that $\mathcal{E}$
has constant rank $r$ on the inverse image of $S_r$.
Thus we may assume $\mathcal{E}$ has constant rank $r$.
We will denote $\mathcal{E}^\vee = \SheafHom(\mathcal{E}, \mathcal{O}_X)$
the dual rank $r$ module.

\medskip\noindent
By cohomology and base change (more precisely by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general})
we see that $E = Rf_*\mathcal{E}$ is a perfect object of the
derived category of $S$ and that its formation commutes with
arbitrary change of base. Similarly for $E' = Rf_*\mathcal{E}^\vee$.
Since there is never any cohomology in degrees $< 0$, we see that
$E$ and $E'$ have (locally) tor-amplitude in $[0, b]$ for some $b$.
Observe that for any $g : T \to S$ we have
$p_*(q^*\mathcal{E}) = H^0(Lg^*E)$ and
$p_*(q^*\mathcal{E}^\vee) = H^0(Lg^*E')$.
Let $j : Z \to S$ and $j' : Z' \to S$ be immersions
of finite presentation constructed in Derived Categories of Schemes, Lemma
\ref{perfect-lemma-locally-closed-where-H0-locally-free}
for $E$ and $E'$ with $a = 0$ and $r = r$; these are roughly speaking
characterized by the property that $H^0(Lj^*E)$ and $H^0((j')^*E')$
are finite locally free modules compatible with pullback.

\medskip\noindent
Let $g : T \to S$ be a morphism. If there exists an $\mathcal{N}$
as in the lemma, then, using the projection formula
Cohomology, Lemma \ref{cohomology-lemma-projection-formula},
we see that the modules
$$
p_*(q^*\mathcal{L}) \cong
p_*(p^*\mathcal{N}) \cong
\mathcal{N} \otimes_{\mathcal{O}_T} p_*\mathcal{O}_{X_T} \cong
\mathcal{N}\quad\text{and similarly }\quad
p_*(q^*\mathcal{E}^\vee) \cong \mathcal{N}^\vee
$$
are finite locally free modules of rank $r$
and remain so after any further base change $T' \to T$.
Hence in this case $T \to S$ factors through $j$ and through $j'$.
Thus we may replace $S$ by $Z \times_S Z'$ and assume that
$f_*\mathcal{E}$ and $f_*\mathcal{E}^\vee$ are finite locally free
$\mathcal{O}_S$-modules of rank $r$
whose formation commutes with arbitrary change of base
(small detail omitted).

\medskip\noindent
In this sitation if $g : T \to S$ be a morphism and there exists an
$\mathcal{N}$ as in the lemma, then the map (cup product in degree $0$)
$$
p_*(q^*\mathcal{E})
\otimes_{\mathcal{O}_T}
p_*(q^*\mathcal{E}^\vee)
\longrightarrow \mathcal{O}_T
$$
is a perfect pairing. Conversely, if this cup product map is a
perfect pairing, then we see that locally on $T$ we may choose a
basis of sections
$\sigma_1, \ldots, \sigma_r$ in $p_*(q^*\mathcal{E})$
and $\tau_1, \ldots, \tau_r$ in $p_*(q^*\mathcal{E}^\vee)$
whose products satisfy $\sigma_i \tau_j = \delta_{ij}$.
Thinking of $\sigma_i$ as a section of $q^*\mathcal{E}$ on $X_T$
and $\tau_j$ as a section of $q^*\mathcal{E}^\vee$ on $X_T$,
we conclude that
$$
\sigma_1, \ldots, \sigma_r :
\mathcal{O}_{X_T}^{\oplus r}
\longrightarrow
q^*\mathcal{E}
$$
is an isomorphism with inverse given by
$$
\tau_1, \ldots, \tau_r :
q^*\mathcal{E}
\longrightarrow
\mathcal{O}_{X_T}^{\oplus r}
$$
In other words, we see that $p^*p_*q^*\mathcal{E} \cong q^*\mathcal{E}$.
But the condition that the cupproduct is nondegenerate picks
out a retrocompact open subscheme (namely, the locus where a suitable
determinant is nonzero) and the proof is complete.
\end{proof}

\noindent
The lemma above in particular tells us, that if a vector bundle is
trivial on fibres for a proper flat family of proper spaces, then
it is the pull back of a vector bundle. Let's spell this out a bit.

\begin{lemma}
\label{lemma-trivial-on-fibres}
Let $f : X \to S$ be a flat, proper morphism of finite presentation
such that $f_*\mathcal{O}_X = \mathcal{O}_S$ and this remains
true after arbitrary base change. Let $\mathcal{E}$ be a finite
locally free $\mathcal{O}_X$-module. Assume
\begin{enumerate}
\item $\mathcal{E}|_{X_s}$ is isomorphic to
$\mathcal{O}_{X_s}^{\oplus r_s}$ for all $s \in S$, and
\item $S$ is reduced.
\end{enumerate}
Then $\mathcal{E} = f^*\mathcal{N}$ for some finite locally free
$\mathcal{O}_S$-module $\mathcal{N}$.
\end{lemma}

\begin{proof}
Namely, in this case the locally closed immersion $j : Z \to S$ of
Lemma \ref{lemma-diagonal-picard-flat-proper}
is bijective and hence a
closed immersion. But since $S$ is reduced, $j$ is an isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-triviality-generic-fibre-valuation-ring}
Let $f : X \to S$ be a proper flat morphism of finite presentation.
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module.
Assume
\begin{enumerate}
\item $S$ is the spectrum of a valuation ring,
\item $\mathcal{L}$ is trivial on the generic fibre $X_\eta$ of $f$,
\item the closed fibre $X_0$ of $f$ is integral,
\item $H^0(X_\eta, \mathcal{O}_{X_\eta})$ is equal to the function field of $S$.
\end{enumerate}
Then $\mathcal{L}$ is trivial.
\end{lemma}

\begin{proof}
Write $S = \Spec(A)$. We will first prove the lemma when $A$ is a
discrete valuation ring (as this is the case most often used in practice).
Let $\pi \in A$ be a uniformizer.
Take a trivializing section $s \in \Gamma(X_\eta, \mathcal{L}_\eta)$.
After replacing $s$ by $\pi^n s$ if necessary
we can assume that $s \in \Gamma(X, \mathcal{L})$.
If $s|_{X_0} = 0$, then we see
that $s$ is divisible by $\pi$ (because $X_0$ is the scheme theoretic
fibre and $X$ is flat over $A$). Thus we may assume that $s|_{X_0}$
is nonzero. Then the zero locus $Z(s)$ of $s$ is contained in $X_0$
but does not contain the generic point of $X_0$ (because $X_0$ is integral).
This means that the $Z(s)$ has codimension $\geq 2$ in $X$ which contradicts
Divisors, Lemma \ref{divisors-lemma-effective-Cartier-codimension-1}
unless $Z(s) = \emptyset$ as desired.

\medskip\noindent
Proof in the general case. Since the valuation ring $A$ is
coherent (Algebra, Example \ref{algebra-example-valuation-ring-coherent})
we see that $H^0(X, \mathcal{L})$ is a coherent $A$-module, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-over-coherent-ring}.
Equivalently, $H^0(X, \mathcal{L})$ is a finitely presented
$A$-module (Algebra, Lemma \ref{algebra-lemma-coherent-ring}).
Since $H^0(X, \mathcal{L})$ is torsion free (by flatness of $X$ over $A$),
we see from More on Algebra, Lemma
\ref{more-algebra-lemma-generalized-valuation-ring-modules}
that $H^0(X, \mathcal{L}) = A^{\oplus n}$ for some $n$.
By flat base change (Cohomology of Schemes, Lemma
\ref{coherent-lemma-flat-base-change-cohomology})
we have
$$
K = H^0(X_\eta, \mathcal{O}_{X_\eta}) \cong
H^0(X_\eta, \mathcal{L}_\eta) =
H^0(X, \mathcal{L}) \otimes_A K
$$
where $K$ is the fraction field of $A$. Thus $n = 1$.
Pick a generator $s \in H^0(X, \mathcal{L})$.
Let $\mathfrak m \subset A$ be the maximal ideal.
Then $\kappa = A/\mathfrak m = \colim A/\pi$ where
this is a filtered colimit over nonzero $\pi \in \mathfrak m$
(here we use that $A$ is a valuation ring).
Thus $X_0 = \lim X \times_S \Spec(A/\pi)$.
If $s|_{X_0}$ is zero, then for some $\pi$
we see that $s$ restricts to zero on $X \times_S \Spec(A/\pi)$, see
Limits, Lemma \ref{limits-lemma-descend-section}.
But if this happens, then $\pi^{-1} s$ is
a global section of $\mathcal{L}$ which contradicts
the fact that $s$ is a generator of $H^0(X, \mathcal{L})$.
Thus $s|_{X_0}$ is not zero. Let $Z(s) \subset X$ be the zero scheme of $s$.
Since $s|_{X_0}$ is not zero and since $X_0$ is integral,
we see that $Z(s)_0 \subset X_0$ is an effective Cartier divisor.
Since $f$ is proper and $S$ is local, every point of $Z(s)$
specializes to a point of $Z(s)_0$. Thus by
Divisors, Lemma \ref{divisors-lemma-fibre-Cartier} part (3)
we see that $Z(s)$ is a relative effective Cartier divisor,
in particular $Z(s) \to S$ is flat.
Hence if $Z(s)$ were nonemtpy, then $Z(s)_\eta$ would be nonempty
which contradicts the fact that $s|_{X_\eta}$ is a trivialization
of $\mathcal{L}_\eta$. Thus $Z(s) = \emptyset$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-get-a-closed}
Let $f : X \to S$ and $\mathcal{E}$ be as in
Lemma \ref{lemma-diagonal-picard-flat-proper}
and in addition assume $\mathcal{E}$ is an invertible $\mathcal{O}_X$-module.
If moreover the geometric fibres of $f$ are
integral, then $Z$ is closed in $S$.
\end{lemma}

\begin{proof}
Since $j : Z \to S$ is of finite presentation, it suffices
to show: for any morphism $g : \Spec(A) \to S$ where $A$ is a
valuation ring with fraction field $K$ such that $g(\Spec(K)) \in j(Z)$
we have $g(\Spec(A)) \subset j(Z)$. See
Morphisms, Lemma \ref{morphisms-lemma-reach-points-scheme-theoretic-image}.
This follows from Lemma \ref{lemma-triviality-generic-fibre-valuation-ring}
and the characterization of $j : Z \to S$ in
Lemma \ref{lemma-diagonal-picard-flat-proper}.
\end{proof}

\begin{lemma}
\label{lemma-H1-O-picard-flat-proper}
Consider a commutative diagram of schemes
$$
\xymatrix{
X' \ar[rr] \ar[dr]_{f'} & & X \ar[dl]^f \\
& S
}
$$
with $f' : X' \to S$ and $f : X \to S$ satisfying the hypotheses of
Lemma \ref{lemma-diagonal-picard-flat-proper}.
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module
and let $\mathcal{L}'$ be the pullback to $X'$. Let $Z \subset S$,
resp.\ $Z' \subset S$ be the locally closed subscheme constructed
in Lemma \ref{lemma-diagonal-picard-flat-proper}
for $(f, \mathcal{L})$, resp.\ $(f', \mathcal{L}')$
so that $Z \subset Z'$. If $s \in Z$ and
$$
H^1(X_s, \mathcal{O}) \longrightarrow H^1(X'_s, \mathcal{O})
$$
is injective, then $Z \cap U = Z' \cap U$ for some open neighbourhood
$U$ of $s$.
\end{lemma}

\begin{proof}
We may replace $S$ by $Z'$. After shrinking $S$ to an affine open neighbourhood
of $s$ we may assume that $\mathcal{L}' = \mathcal{O}_{X'}$.
Let $E = Rf_*\mathcal{L}$ and $E' = Rf'_*\mathcal{L}' = Rf'_*\mathcal{O}_{X'}$.
These are perfect complexes whose formation commutes with arbitrary
change of base (Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}).
In particular we see that
$$
E \otimes_{\mathcal{O}_S}^\mathbf{L} \kappa(s) =
R\Gamma(X_s, \mathcal{L}_s) = R\Gamma(X_s, \mathcal{O}_{X_s})
$$
The second equality because $s \in Z$. Set
$h_i = \dim_{\kappa(s)} H^i(X_s, \mathcal{O}_{X_s})$.
After shrinking $S$ we can represent $E$ by a complex
$$
\mathcal{O}_S \to \mathcal{O}_S^{\oplus h_1} \to
\mathcal{O}_S^{\oplus h_2} \to \ldots
$$
see More on Algebra, Lemma
\ref{more-algebra-lemma-lift-perfect-from-residue-field}
(strictly speaking this also uses
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded} and
\ref{perfect-lemma-perfect-affine}). Similarly, we may assume $E'$
is represented by a complex
$$
\mathcal{O}_S \to \mathcal{O}_S^{\oplus h'_1} \to
\mathcal{O}_S^{\oplus h'_2} \to \ldots
$$
where $h'_i = \dim_{\kappa(s)} H^i(X'_s, \mathcal{O}_{X'_s})$.
By functoriality of cohomology we have a map
$$
E \longrightarrow E'
$$
in $D(\mathcal{O}_S)$ whose formation commutes with change of base.
Since the complex representing $E$ is a finite complex of finite free
modules and since $S$ is affine, we can choose a map of complexes
$$
\xymatrix{
\mathcal{O}_S \ar[r]_d \ar[d]_a &
\mathcal{O}_S^{\oplus h_1} \ar[r] \ar[d]_b &
\mathcal{O}_S^{\oplus h_2} \ar[r] \ar[d]_c & \ldots \\
\mathcal{O}_S \ar[r]^{d'} &
\mathcal{O}_S^{\oplus h'_1} \ar[r] &
\mathcal{O}_S^{\oplus h'_2} \ar[r] & \ldots
}
$$
representing the given map $E \to E'$. Since $s \in Z$ we see that
the trivializing section of $\mathcal{L}_s$ pulls back to a trivializing
section of $\mathcal{L}'_s = \mathcal{O}_{X'_s}$. Thus
$a \otimes \kappa(s)$ is an isomorphism, hence after shrinking $S$
we see that $a$ is an isomorphism. Finally, we use the hypothesis
that $H^1(X_s, \mathcal{O}) \to H^1(X'_s, \mathcal{O})$
is injective, to see that there exists a $h_1 \times h_1$ minor of the
matrix defining $b$ which maps to a nonzero
element in $\kappa(s)$. Hence after shrinking $S$ we may assume
that $b$ is injective. However, since $\mathcal{L}' = \mathcal{O}_{X'}$
we see that $d' = 0$. It follows that $d = 0$. In this way we see
that the trivializing section of $\mathcal{L}_s$ lifts to a section
of $\mathcal{L}$ over $X$. A straightforward topological argument (omitted)
shows that this means that $\mathcal{L}$ is trivial after possibly
shrinking $S$ a bit further.
\end{proof}

\begin{lemma}
\label{lemma-H1-O-multiple-picard-flat-proper}
Consider $n$ commutative diagrams of schemes
$$
\xymatrix{
X_i \ar[rr] \ar[dr]_{f_i} & & X \ar[dl]^f \\
& S
}
$$
with $f_i : X_i \to S$ and $f : X \to S$ satisfying the hypotheses of
Lemma \ref{lemma-diagonal-picard-flat-proper}.
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module
and let $\mathcal{L}_i$ be the pullback to $X_i$. Let $Z \subset S$,
resp.\ $Z_i \subset S$ be the locally closed subscheme constructed
in Lemma \ref{lemma-diagonal-picard-flat-proper}
for $(f, \mathcal{L})$, resp.\ $(f_i, \mathcal{L}_i)$
so that $Z \subset \bigcap_{i = 1, \ldots, n} Z_i$. If $s \in Z$ and
$$
H^1(X_s, \mathcal{O}) \longrightarrow
\bigoplus\nolimits_{i = 1, \ldots, n} H^1(X_{i, s}, \mathcal{O})
$$
is injective, then $Z \cap U = (\bigcap_{i = 1, \ldots, n} Z_i) \cap U$
(scheme theoretic intersection) for some open neighbourhood $U$ of $s$.
\end{lemma}

\begin{proof}
This lemma is a variant of Lemma \ref{lemma-H1-O-picard-flat-proper}
and we strongly urge the reader to read that proof first; this proof
is basically a copy of that proof with minor modifications. It follows
from the description of (scheme valued) points of $Z$ and the $Z_i$
that $Z \subset \bigcap_{i = 1, \ldots, n} Z_i$ where we take the
scheme theoretic intersection. Thus we may replace $S$ by the scheme
theoretic intersection $\bigcap_{i = 1, \ldots, n} Z_i$. After shrinking
$S$ to an affine open neighbourhood of $s$ we may assume that
$\mathcal{L}_i = \mathcal{O}_{X_i}$ for $i = 1, \ldots, n$.
Let $E = Rf_*\mathcal{L}$ and
$E_i = Rf_{i, *}\mathcal{L}_i = Rf_{i, *}\mathcal{O}_{X_i}$.
These are perfect complexes whose formation commutes with arbitrary
change of base (Derived Categories of Schemes, Lemma
\ref{perfect-lemma-flat-proper-perfect-direct-image-general}).
In particular we see that
$$
E \otimes_{\mathcal{O}_S}^\mathbf{L} \kappa(s) =
R\Gamma(X_s, \mathcal{L}_s) = R\Gamma(X_s, \mathcal{O}_{X_s})
$$
The second equality because $s \in Z$. Set
$h_j = \dim_{\kappa(s)} H^j(X_s, \mathcal{O}_{X_s})$.
After shrinking $S$ we can represent $E$ by a complex
$$
\mathcal{O}_S \to \mathcal{O}_S^{\oplus h_1} \to
\mathcal{O}_S^{\oplus h_2} \to \ldots
$$
see More on Algebra, Lemma
\ref{more-algebra-lemma-lift-perfect-from-residue-field}
(strictly speaking this also uses
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded} and
\ref{perfect-lemma-perfect-affine}). Similarly, we may assume $E_i$
is represented by a complex
$$
\mathcal{O}_S \to \mathcal{O}_S^{\oplus h_{i, 1}} \to
\mathcal{O}_S^{\oplus h_{i, 2}} \to \ldots
$$
where $h_{i, j} = \dim_{\kappa(s)} H^j(X_{i, s}, \mathcal{O}_{X_{i, s}})$.
By functoriality of cohomology we have a map
$$
E \longrightarrow E_i
$$
in $D(\mathcal{O}_S)$ whose formation commutes with change of base.
Since the complex representing $E$ is a finite complex of finite free
modules and since $S$ is affine, we can choose a map of complexes
$$
\xymatrix{
\mathcal{O}_S \ar[r]_d \ar[d]_{a_i} &
\mathcal{O}_S^{\oplus h_1} \ar[r] \ar[d]_{b_i} &
\mathcal{O}_S^{\oplus h_2} \ar[r] \ar[d]_{c_i} & \ldots \\
\mathcal{O}_S \ar[r]^{d_i} &
\mathcal{O}_S^{\oplus h_{i, 1}} \ar[r] &
\mathcal{O}_S^{\oplus h_{i, 2}} \ar[r] & \ldots
}
$$
representing the given map $E \to E_i$. Since $s \in Z$ we see that
the trivializing section of $\mathcal{L}_s$ pulls back to a trivializing
section of $\mathcal{L}_{i, s} = \mathcal{O}_{X_{i, s}}$. Thus
$a_i \otimes \kappa(s)$ is an isomorphism, hence after shrinking $S$
we see that $a_i$ is an isomorphism. Finally, we use the hypothesis
that $H^1(X_s, \mathcal{O}) \to
\bigoplus_{i = 1, \ldots, n} H^1(X_{i, s}, \mathcal{O})$
is injective, to see that there exists a $h_1 \times h_1$ minor of the
matrix defining $\oplus b_i$ which maps to a nonzero
element in $\kappa(s)$. Hence after shrinking $S$ we may assume that
$(b_1, \ldots, b_n) : \mathcal{O}_S^{h_1}
\to \bigoplus_{i = 1, \ldots, n} \mathcal{O}_S^{h_{i, 1}}$
is injective. However, since $\mathcal{L}_i = \mathcal{O}_{X_i}$
we see that $d_i = 0$ for $i = 1, \ldots n$. It follows that $d = 0$
because $(b_1, \ldots, b_n) \circ d = (\oplus d_i) \circ (a_1, \ldots, a_n)$.
In this way we see
that the trivializing section of $\mathcal{L}_s$ lifts to a section
of $\mathcal{L}$ over $X$. A straightforward topological argument (omitted)
shows that this means that $\mathcal{L}$ is trivial after possibly
shrinking $S$ a bit further.
\end{proof}

\begin{lemma}
\label{lemma-pic-of-product}
Let $f : X \to S$ and $g : Y \to S$ be morphisms of schemes
satisfying the hypotheses of Lemma \ref{lemma-diagonal-picard-flat-proper}.
Let $\sigma : S \to X$ and $\tau : S \to Y$ be sections of
$f$ and $g$. Let $s \in S$.
Let $\mathcal{L}$ be an invertible sheaf on $X \times_S Y$.
If $(1 \times \tau)^*\mathcal{L}$ on $X$, $(\sigma \times 1)^*\mathcal{L}$
on $Y$, and $\mathcal{L}|_{(X \times_S Y)_s}$ are trivial, then
there is an open neighbourhood $U$ of $s$ such that
$\mathcal{L}$ is trivial over $(X \times_S Y)_U$.
\end{lemma}

\begin{proof}
By K\"unneth (Varieties, Lemma \ref{varieties-lemma-kunneth})
the map
$$
H^1(X_s \times_{\Spec(\kappa(s))} Y_s, \mathcal{O}) \to
H^1(X_s, \mathcal{O}) \oplus H^1(Y_s, \mathcal{O})
$$
is injective. Thus we may
apply Lemma \ref{lemma-H1-O-multiple-picard-flat-proper}
to the two morphisms
$$
1 \times \tau : X \to X \times_S Y
\quad\text{and}\quad
\sigma \times 1 : Y \to X \times_S Y
$$
to conclude.
\end{proof}

\begin{theorem}[Theorem of the cube]
\label{theorem-of-the-cube}
Let $S$ be a scheme. Let $X$, $Y$, and $Z$ be schemes over $S$.
Let $x : S \to X$ and $y : S \to Y$ be sections of the structure morphisms.
Let $\mathcal{L}$ be an invertible module on $X \times_S Y \times_S Z$. If
\begin{enumerate}
\item $X \to S$ and $Y \to S$ are flat, proper morphisms
of finite presentation with geometrically integral fibres,
\item the pullbacks of $\mathcal{L}$ by
$x \times \text{id}_Y \times \text{id}_Z$ and
$\text{id}_X \times y \times \text{id}_Z$
are trivial over $Y \times_S Z$ and $X \times_S Z$,
\item there is a point $z \in Z$ such that $\mathcal{L}$
restricted to $X \times_S Y \times_S z$ is trivial, and
\item $Z$ is connected,
\end{enumerate}
then $\mathcal{L}$ is trivial.
\end{theorem}

\noindent
An often used special case is the following.
Let $k$ be a field. Let $X, Y, Z$ be varieties with
$k$-rational points $x, y, z$. Let $\mathcal{L}$ be an invertible
module on $X \times Y \times Z$. If
\begin{enumerate}
\item $\mathcal{L}$ is trivial over
$x \times Y \times Z$, $X \times y \times Z$, and $X \times Y \times z$, and
\item $X$ and $Y$ are geometrically integral and proper over $k$,
\end{enumerate}
then $\mathcal{L}$ is trivial.

\begin{proof}
Observe that the morphism $X \times_S Y \to S$ is a flat, proper morphism
of finite presentation whose geometrically integral fibres
(see Varieties, Lemmas \ref{varieties-lemma-geometrically-integral},
\ref{varieties-lemma-bijection-irreducible-components},
and \ref{varieties-lemma-geometrically-reduced-any-base-change} for the
statement about the fibres). By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-proper-flat-geom-red-connected}
we see that the pushforward of the structure sheaf by $X \to S$, $Y \to S$, or
$X \times_S Y \to S$ is the structure sheaf of $S$ and the same remains true
after any base change. Thus we may apply
Lemma \ref{lemma-diagonal-picard-flat-proper} to the morphism
$$
p : X \times_S Y \times_S Z \longrightarrow Z
$$
and the invertible module $\mathcal{L}$ to get a ``universal'' locally closed
subscheme $Z' \subset Z$ such that $\mathcal{L}|_{X \times_S Y \times_S Z'}$
is the pullback of an invertible module $\mathcal{N}$ on $Z'$.
The existence of $z$ shows that $Z'$ is nonempty. By
Lemma \ref{lemma-get-a-closed}
we see that $Z' \subset Z$ is a closed subscheme.
Let $z' \in Z'$ be a point.
Observe that we may write $p$ as the product morphism
$$
(X \times_S Z) \times_Z (Y \times_S Z) \longrightarrow Z
$$
Hence we may apply Lemma \ref{lemma-pic-of-product}
to the morphism $p$, the point $z'$, and the sections
$\sigma : Z \to X \times_S Z$ and $\tau : Z \to Y \times_S Z$
given by $x$ and $y$. We conclude that $Z'$ is open.
Hence $Z' = Z$ and $\mathcal{L} = p^*\mathcal{N}$
for some invertible module $\mathcal{N}$ on $Z$.
Pulling back via
$x \times y \times \text{id}_Z : Z  \to X \times_S Y \times_S Z$
we obtain on the one hand $\mathcal{N}$ and on the other hand
we obtain the trivial invertible module by assumption (2).
Thus $\mathcal{N} = \mathcal{O}_Z$ and the proof is complete.
\end{proof}









\section{Limit arguments}
\label{section-limits}

\noindent
Some lemmas involving limits of schemes, and Noetherian approximation.
We stick mostly to the affine case. Some of these lemmas are special
cases of lemmas in the chapter on limits.

\begin{lemma}
\label{lemma-Noetherian-approximation}
Let $f : X \to S$ be a morphism of affine schemes, which is of finite
presentation. Then there exists a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l]^g \ar[d]^f \\
S_0 & S \ar[l]
}
$$
such that
\begin{enumerate}
\item $X_0$, $S_0$ are affine schemes,
\item $S_0$ of finite type over $\mathbf{Z}$,
\item $f_0$ is of finite type.
\end{enumerate}
\end{lemma}

\begin{proof}
Write $S = \Spec(A)$ and $X = \Spec(B)$.
As $f$ is of finite presentation we see that
$B$ is of finite presentation as an $A$-algebra, see
Morphisms,
Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}.
Thus the lemma follows from
Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-module}
Let $f : X \to S$ be a morphism of affine schemes, which is of finite
presentation. Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module
of finite presentation. Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that there exists a coherent $\mathcal{O}_{X_0}$-module $\mathcal{F}_0$
with $g^*\mathcal{F}_0 = \mathcal{F}$.
\end{lemma}

\begin{proof}
Write $S = \Spec(A)$, $X = \Spec(B)$, and
$\mathcal{F} = \widetilde{M}$. As $f$ is of finite presentation we see that
$B$ is of finite presentation as an $A$-algebra, see
Morphisms,
Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}.
As $\mathcal{F}$ is of finite presentation over $\mathcal{O}_X$ we see that
$M$ is of finite presentation as a $B$-module, see
Properties, Lemma \ref{properties-lemma-finite-presentation-module}.
Thus the lemma follows from
Algebra, Lemma \ref{algebra-lemma-limit-module-finite-presentation}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-flat-module}
Let $f : X \to S$ be a morphism of affine schemes, which is of finite
presentation. Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module
of finite presentation and flat over $S$. Then we may choose a diagram as in
Lemma \ref{lemma-Noetherian-approximation-module}
and sheaf $\mathcal{F}_0$ such that in addition $\mathcal{F}_0$
is flat over $S_0$.
\end{lemma}

\begin{proof}
Write $S = \Spec(A)$, $X = \Spec(B)$, and
$\mathcal{F} = \widetilde{M}$. As $f$ is of finite presentation we see that
$B$ is of finite presentation as an $A$-algebra, see
Morphisms,
Lemma \ref{morphisms-lemma-locally-finite-presentation-characterize}.
As $\mathcal{F}$ is of finite presentation over $\mathcal{O}_X$ we see that
$M$ is of finite presentation as a $B$-module, see
Properties, Lemma \ref{properties-lemma-finite-presentation-module}.
As $\mathcal{F}$ is flat over $S$ we see that $M$ is flat over $A$, see
Morphisms, Lemma \ref{morphisms-lemma-flat-module-characterize}.
Thus the lemma follows from
Algebra, Lemma \ref{algebra-lemma-flat-finite-presentation-limit-flat}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-flat}
Let $f : X \to S$ be a morphism of affine schemes, which is of finite
presentation and flat. Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ is flat.
\end{lemma}

\begin{proof}
This is a special case of
Lemma \ref{lemma-Noetherian-approximation-flat-module}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-smooth}
Let $f : X \to S$ be a morphism of affine schemes, which is smooth.
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ is smooth.
\end{lemma}

\begin{proof}
Write $S = \Spec(A)$, $X = \Spec(B)$, and
as $f$ is smooth we see that $B$ is smooth as an $A$-algebra, see
Morphisms,
Lemma \ref{morphisms-lemma-smooth-characterize}.
Hence the lemma follows from
Algebra, Lemma \ref{algebra-lemma-finite-presentation-fs-Noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-geometrically-reduced}
Let $f : X \to S$ be a morphism of affine schemes, which is
of finite presentation with geometrically reduced fibres.
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ has geometrically reduced fibres.
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-Noetherian-approximation}
to get a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l]^g \ar[d]^f \\
S_0 & S \ar[l]_h
}
$$
of affine schemes with $X_0 \to S_0$ a finite type morphism of
schemes of finite type over $\mathbf{Z}$. By
Lemma \ref{lemma-geometrically-reduced-constructible}
the set $E \subset S_0$ of points where the fibre of
$f_0$ is geometrically reduced is a constructible subset. By
Lemma \ref{lemma-base-change-fibres-geometrically-reduced}
we have $h(S) \subset E$. Write $S_0 = \Spec(A_0)$ and
$S = \Spec(A)$. Write $A = \colim_i A_i$ as a
direct colimit of finite type $A_0$-algebras. By
Limits, Lemma \ref{limits-lemma-limit-contained-in-constructible}
we see that $\Spec(A_i) \to S_0$ has image contained in $E$
for some $i$. After replacing $S_0$ by $\Spec(A_i)$ and
$X_0$ by $X_0 \times_{S_0} \Spec(A_i)$ we see that
all fibres of $f_0$ are geometrically reduced.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-geometrically-irreducible}
Let $f : X \to S$ be a morphism of affine schemes, which is
of finite presentation with geometrically irreducible fibres.
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ has geometrically irreducible fibres.
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-Noetherian-approximation}
to get a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l]^g \ar[d]^f \\
S_0 & S \ar[l]_h
}
$$
of affine schemes with $X_0 \to S_0$ a finite type morphism of
schemes of finite type over $\mathbf{Z}$. By
Lemma \ref{lemma-nr-geom-irreducible-components-constructible}
the set $E \subset S_0$ of points where the fibre of
$f_0$ is geometrically irreducible is a constructible subset. By
Lemma \ref{lemma-base-change-fibres-geometrically-irreducible}
we have $h(S) \subset E$. Write $S_0 = \Spec(A_0)$ and
$S = \Spec(A)$. Write $A = \colim_i A_i$ as a
direct colimit of finite type $A_0$-algebras. By
Limits, Lemma \ref{limits-lemma-limit-contained-in-constructible}
we see that $\Spec(A_i) \to S_0$ has image contained in $E$
for some $i$. After replacing $S_0$ by $\Spec(A_i)$ and
$X_0$ by $X_0 \times_{S_0} \Spec(A_i)$ we see that
all fibres of $f_0$ are geometrically irreducible.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-geometrically-connected}
Let $f : X \to S$ be a morphism of affine schemes, which is
of finite presentation with geometrically connected fibres.
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ has geometrically connected fibres.
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-Noetherian-approximation}
to get a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l]^g \ar[d]^f \\
S_0 & S \ar[l]_h
}
$$
of affine schemes with $X_0 \to S_0$ a finite type morphism of
schemes of finite type over $\mathbf{Z}$. By
Lemma \ref{lemma-nr-geom-connected-components-constructible}
the set $E \subset S_0$ of points where the fibre of
$f_0$ is geometrically connected is a constructible subset. By
Lemma \ref{lemma-base-change-fibres-geometrically-connected}
we have $h(S) \subset E$. Write $S_0 = \Spec(A_0)$ and
$S = \Spec(A)$. Write $A = \colim_i A_i$ as a
direct colimit of finite type $A_0$-algebras. By
Limits, Lemma \ref{limits-lemma-limit-contained-in-constructible}
we see that $\Spec(A_i) \to S_0$ has image contained in $E$
for some $i$. After replacing $S_0$ by $\Spec(A_i)$ and
$X_0$ by $X_0 \times_{S_0} \Spec(A_i)$ we see that
all fibres of $f_0$ are geometrically connected.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-dimension-d}
Let $d \geq 0$ be an integer.
Let $f : X \to S$ be a morphism of affine schemes, which is
of finite presentation all of whose fibres have dimension $d$.
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition all fibres of $f_0$ have dimension $d$.
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-Noetherian-approximation}
to get a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l]^g \ar[d]^f \\
S_0 & S \ar[l]_h
}
$$
of affine schemes with $X_0 \to S_0$ a finite type morphism of
schemes of finite type over $\mathbf{Z}$. By
Lemma \ref{lemma-dimension-fibres-constructible}
the set $E \subset S_0$ of points where the fibre of
$f_0$ has dimension $d$ is a constructible subset. By
Lemma \ref{lemma-base-change-dimension-fibres}
we have $h(S) \subset E$. Write $S_0 = \Spec(A_0)$ and
$S = \Spec(A)$. Write $A = \colim_i A_i$ as a
direct colimit of finite type $A_0$-algebras. By
Limits, Lemma \ref{limits-lemma-limit-contained-in-constructible}
we see that $\Spec(A_i) \to S_0$ has image contained in $E$
for some $i$. After replacing $S_0$ by $\Spec(A_i)$ and
$X_0$ by $X_0 \times_{S_0} \Spec(A_i)$ we see that
all fibres of $f_0$ have dimension $d$.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-standard-syntomic}
Let $f : X \to S$ be a morphism of affine schemes, which is
standard syntomic (see
Morphisms, Definition \ref{morphisms-definition-syntomic}).
Then there exists a diagram as in
Lemma \ref{lemma-Noetherian-approximation}
such that in addition $f_0$ is standard syntomic.
\end{lemma}

\begin{proof}
This lemma is a copy of
Algebra,
Lemma \ref{algebra-lemma-relative-global-complete-intersection-Noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-approximation-combine}
(Noetherian approximation and combining properties.)
Let $P$, $Q$ be properties of morphisms of schemes which are stable
under base change. Let $f : X \to S$ be a morphism of finite presentation
of affine schemes. Assume we can find cartesian diagrams
$$
\vcenter{
\xymatrix{
X_1 \ar[d]_{f_1} & X \ar[l] \ar[d]^f \\
S_1 & S \ar[l]
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
X_2 \ar[d]_{f_2} & X \ar[l] \ar[d]^f \\
S_2 & S \ar[l]
}
}
$$
of affine schemes, with $S_1$, $S_2$ of finite type over $\mathbf{Z}$
and $f_1$, $f_2$ of finite type such that $f_1$ has property $P$
and $f_2$ has property $Q$. Then we can find a cartesian diagram
$$
\xymatrix{
X_0 \ar[d]_{f_0} & X \ar[l] \ar[d]^f \\
S_0 & S \ar[l]
}
$$
of affine schemes with $S_0$ of finite type over $\mathbf{Z}$
and $f_0$ of finite type such that $f_0$ has both property $P$ and
property $Q$.
\end{lemma}

\begin{proof}
The given pair of diagrams correspond to cocartesian diagrams of rings
$$
\vcenter{
\xymatrix{
B_1 \ar[r] & B \\
A_1 \ar[u] \ar[r] & A \ar[u]
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
B_2 \ar[r] & B \\
A_2 \ar[u] \ar[r] & A \ar[u]
}
}
$$
Let $A_0 \subset A$ be a finite type $\mathbf{Z}$-subalgebra of $A$
containing the image of both $A_1 \to A$ and $A_2 \to A$. Such a subalgebra
exists because by assumption both $A_1$ and $A_2$ are of finite type over
$\mathbf{Z}$. Note that the rings $B_{0, 1} = B_1 \otimes_{A_1} A_0$
and $B_{0, 2} = B_2 \otimes_{A_2} A_0$ are finite type $A_0$-algebras
with the property that
$B_{0, 1} \otimes_{A_0} A \cong B \cong B_{0, 2} \otimes_{A_0} A$
as $A$-algebras. As $A$ is the directed colimit of its finite type
$A_0$-subalgebras, by
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we may assume after enlarging $A_0$ that there exists an isomorphism
$B_{0, 1} \cong B_{0, 2}$ as $A_0$-algebras. Since properties $P$ and $Q$
are assumed stable under base change we conclude that setting
$S_0 = \Spec(A_0)$ and
$$
X_0 = X_1 \times_{S_1} S_0 =
\Spec(B_{0, 1}) \cong \Spec(B_{0, 2}) = X_2 \times_{S_2} S_0
$$
works.
\end{proof}












\section{\'Etale neighbourhoods}
\label{section-etale-neighbourhoods}

\noindent
It turns out that some properties of morphisms are easier to study
after doing an \'etale base change. It is convenient to introduce the
following terminology.

\begin{definition}
\label{definition-etale-neighbourhood}
Let $S$ be a scheme. Let $s \in S$ be a point.
\begin{enumerate}
\item An {\it \'etale neighbourhood of $(S, s)$} is a
pair $(U, u)$ together with an \'etale morphism
of schemes $\varphi : U \to S$ such that $\varphi(u) = s$.
\item A {\it morphism of \'etale neighbourhoods} $f : (V, v) \to (U, u)$
of $(S, s)$ is simply a morphism of $S$-schemes $f : V \to U$ such
that $f(v) = u$.
\item An {\it elementary \'etale neighbourhood} is an \'etale neighbourhood
$\varphi : (U, u) \to (S, s)$ such that $\kappa(s) = \kappa(u)$.
\end{enumerate}
\end{definition}

\noindent
The notion of an elementary \'etale neighbourhood has many different
names in the literature, for example these are sometimes called
``\'etale neighbourhoods'' (\cite[Page 36]{Milne} or
``strongly \'etale'' (\cite[Page 108]{KPR}).
Here we follow the convention of the paper
\cite{GruRay} by calling them elementary \'etale neighbourhoods.

\medskip\noindent
If $f : (V, v) \to (U, u)$ is a morphism of \'etale
neighbourhoods, then $f$ is automatically \'etale, see
Morphisms, Lemma \ref{morphisms-lemma-etale-permanence}.
Hence it turns $(V, v)$ into an \'etale neighbourhood of
$(U, u)$. Of course, since the composition of \'etale morphisms
is \'etale (Morphisms, Lemma \ref{morphisms-lemma-composition-etale})
we see that conversely any \'etale neighbourhood $(V, v)$ of
$(U, u)$ is an \'etale neighbourhood of $(S, s)$ as well.
We also remark that if $U \subset S$ is an open neighbourhood
of $s$, then $(U, s) \to (S, s)$ is an \'etale neighbourhood.
This follows from the fact that an open immersion is
\'etale (Morphisms, Lemma \ref{morphisms-lemma-open-immersion-etale}).
We will use these remarks without further mention throughout this
section.

\medskip\noindent
Note that $\kappa(u)/\kappa(s)$ is a finite separable extension
if $(U, u) \to (S, s)$ is an \'etale neighbourhood,
see Morphisms, Lemma \ref{morphisms-lemma-etale-at-point}.

\begin{lemma}
\label{lemma-realize-prescribed-residue-field-extension-etale}
Let $S$ be a scheme.
Let $s \in S$.
Let $k/\kappa(s)$ be a finite separable field extension.
Then there exists an \'etale neighbourhood $(U, u) \to (S, s)$
such that the field extension $\kappa(u)/\kappa(s)$ is
isomorphic to $k/\kappa(s)$.
\end{lemma}

\begin{proof}
We may assume $S$ is affine.
In this case the lemma follows from
Algebra, Lemma \ref{algebra-lemma-make-etale-map-prescribed-residue-field}.
\end{proof}

\begin{lemma}
\label{lemma-etale-neighbourhoods-not-quite-filtered}
Let $S$ be a scheme, and let $s$ be a point of $S$.
The category of \'etale neighborhoods has the following properties:
\begin{enumerate}
\item Let $(U_i, u_i)_{i=1, 2}$ be two \'etale neighborhoods of
$s$ in $S$. Then there exists a third \'etale neighborhood
$(U, u)$ and morphisms
$(U, u) \to (U_i, u_i)$, $i = 1, 2$.
\item Let $h_1, h_2: (U, u) \to (U', u')$ be two
morphisms between \'etale neighborhoods of $s$.
Assume $h_1$, $h_2$ induce the same map $\kappa(u') \to \kappa(u)$ of residue
fields. Then there exist an \'etale neighborhood $(U'', u'')$ and a morphism
$h : (U'', u'') \to (U, u)$
which equalizes $h_1$ and $h_2$, i.e., such that
$h_1 \circ h = h_2 \circ h$.
\end{enumerate}
\end{lemma}

\begin{proof}
For part (1), consider the fibre product $U = U_1 \times_S U_2$.
It is \'etale over both $U_1$ and $U_2$ because \'etale morphisms are
preserved under base change, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-etale}.
There is a point of $U$ mapping to both $u_1$ and $u_2$ for example
by the description of points of a fibre product in
Schemes, Lemma \ref{schemes-lemma-points-fibre-product}.
For part (2), define $U''$ as the fibre product
$$
\xymatrix{
U'' \ar[r] \ar[d] & U \ar[d]^{(h_1, h_2)} \\
U' \ar[r]^-\Delta & U' \times_S U'.
}
$$
Since $h_1$ and $h_2$ induce the same map of residue fields
$\kappa(u') \to \kappa(u)$ there exists a point $u'' \in U''$
lying over $u'$ with $\kappa(u'') = \kappa(u')$.
In particular $U'' \not = \emptyset$.
Moreover, since $U'$ is \'etale over $S$, so is the fibre product
$U'\times_S U'$ (see
Morphisms, Lemmas \ref{morphisms-lemma-base-change-etale} and
\ref{morphisms-lemma-composition-etale}).
Hence the vertical arrow $(h_1, h_2)$ is \'etale by
Morphisms, Lemma \ref{morphisms-lemma-etale-permanence}.
Therefore $U''$ is \'etale over $U'$ by base change, and hence also
\'etale over $S$ (because compositions of \'etale morphisms are \'etale).
Thus $(U'', u'')$ is a solution to the problem.
\end{proof}

\begin{lemma}
\label{lemma-elementary-etale-neighbourhoods}
Let $S$ be a scheme, and let $s$ be a point of $S$.
The category of elementary \'etale neighborhoods of $(S, s)$
is cofiltered (see
Categories, Definition \ref{categories-definition-codirected}).
\end{lemma}

\begin{proof}
This is immediate from the definitions and
Lemma \ref{lemma-etale-neighbourhoods-not-quite-filtered}.
\end{proof}

\begin{lemma}
\label{lemma-describe-henselization}
Let $S$ be a scheme. Let $s \in S$. Then we have
$$
\mathcal{O}_{S, s}^h =
\colim_{(U, u)} \mathcal{O}(U)
$$
where the colimit is over the filtered category which is opposite to the
category of elementary \'etale neighbourhoods $(U, u)$ of $(S, s)$.
\end{lemma}

\begin{proof}
Let $\Spec(A) \subset S$ be an affine neighbourhood of $s$.
Let $\mathfrak p \subset A$ be the prime ideal corresponding to $s$.
With these choices we have canonical isomorphisms
$\mathcal{O}_{S, s} = A_{\mathfrak p}$ and $\kappa(s) = \kappa(\mathfrak p)$.
A cofinal system of elementary \'etale neighbourhoods is given by those
elementary \'etale neighbourhoods $(U, u)$ such that $U$ is affine and
$U \to S$ factors through $\Spec(A)$. In other words, we see that
the right hand side is equal to $\colim_{(B, \mathfrak q)} B$
where the colimit is over \'etale $A$-algebras $B$ endowed with a prime
$\mathfrak q$ lying over $\mathfrak p$ with
$\kappa(\mathfrak p) = \kappa(\mathfrak q)$.
Thus the lemma follows from
Algebra, Lemma \ref{algebra-lemma-henselization-different}.
\end{proof}

\noindent
We can lift \'etale neighbourhoods of points on fibres
to the total space.

\begin{lemma}
\label{lemma-lift-etale-neighbourhood-fibre}
\begin{slogan}
Lift \'etale neighbourhood of point on fibre to total space.
\end{slogan}
Let $X \to S$ be a morphism of schemes. Let $x \in X$ with image $s \in S$.
Let $(V, v) \to (X_s, x)$ be an \'etale neighbourhood.
Then there exists an \'etale neighbourhood $(U, u) \to (X, x)$
such that there exists a morphism $(U_s, u) \to (V, v)$
of \'etale neighbourhoods of $(X_s, x)$ which is an open immersion.
\end{lemma}

\begin{proof}
We may assume $X$, $V$, and $S$ affine. Say the morphism
$X \to S$ is given by $A \to B$ the point $x$ by a prime
$\mathfrak q \subset B$, the point $s$ by $\mathfrak p = A \cap \mathfrak q$,
and the morphism $V \to X_s$ by $B \otimes_A \kappa(\mathfrak p) \to C$.
Since $\kappa(\mathfrak p)$ is a localization of
$A/\mathfrak p$ there exists an $f \in A$, $f \not \in \mathfrak p$
and an \'etale ring map $B \otimes_A (A/\mathfrak p)_f \to D$
such that
$$
C = (B \otimes_A \kappa(\mathfrak p))
\otimes_{B \otimes_A (A/\mathfrak p)_f} D
$$
See Algebra, Lemma \ref{algebra-lemma-etale} part (9).
After replacing $A$ by $A_f$ and $B$ by $B_f$ we may assume
$D$ is \'etale over $B \otimes_A A/\mathfrak p = B/\mathfrak p B$.
Then we can apply Algebra, Lemma \ref{algebra-lemma-lift-etale}.
This proves the lemma.
\end{proof}














\section{\'Etale neighbourhoods and branches}
\label{section-etale-nbhds-branches}

\noindent
The number of (geometric) branches of a scheme at a point was
defined in Properties, Section \ref{properties-section-unibranch}.
In Varieties, Section \ref{varieties-section-number-of-branches}
we related this to fibres of the normalization morphism.
In this section we discuss a characterization of this number in terms of
\'etale neighbourhoods.

\begin{lemma}
\label{lemma-nr-minimal-primes}
Let $R = \colim R_i$ be colimit of a directed system of rings
whose transition maps are faithfully flat.
Then the number of minimal primes of $R$
taken as an element of $\{0, 1, 2, \ldots, \infty\}$
is the supremum of the numbers of minimal primes of the $R_i$.
\end{lemma}

\begin{proof}
If $A \to B$ is a flat ring map, then $\Spec(B) \to \Spec(A)$
maps minimal primes to minimal primes by going down
(Algebra, Lemma \ref{algebra-lemma-flat-going-down}).
If $A \to B$ is faithfully flat, then every minimal
prime is the image of a minimal prime (by
Algebra, Lemma \ref{algebra-lemma-ff-rings} and
\ref{algebra-lemma-minimal-prime-image-minimal-prime}).
Hence the number of minimal primes of $R_i$ is
$\geq$ the number of minimal primes of $R_{i'}$ if $i \leq i'$.
By Algebra, Lemma \ref{algebra-lemma-colimit-faithfully-flat}
each of the maps $R_i \to R$ is
faithfully flat and we also see that
the number of minimal primes of $R$ is
$\geq$ the number of minimal primes of $R_i$.
Finally, suppose that $\mathfrak q_1, \ldots, \mathfrak q_n$
are pairwise distinct minimal primes of $R$. Then we can
find an $i$ such that $R_i \cap \mathfrak q_1, \ldots, R_i \cap \mathfrak q_n$
are pairwise distinct (as sets and hence as prime ideals).
This implies the lemma.
\end{proof}

\begin{lemma}
\label{lemma-nr-branches}
Let $X$ be a scheme and $x \in X$ a point. Then
\begin{enumerate}
\item the number of branches of $X$ at $x$ is equal to
the supremum of the number of irreducible components of $U$
passing through $u$ taken over elementary \'etale neighbourhoods
$(U, u) \to (X, x)$,
\item the number of geometric branches of $X$ at $x$ is equal to
the supremum of the number of irreducible components of $U$
passing through $u$ taken over \'etale neighbourhoods
$(U, u) \to (X, x)$,
\item $X$ is unibranch at $x$ if and only if for every
elementary \'etale neighbourhood $(U, u) \to (X, x)$ there
is exactly one irreducible component of $U$ passing through $u$, and
\item $X$ is geometrically unibranch at $x$ if and only if for every
\'etale neighbourhood $(U, u) \to (X, x)$ there
is exactly one irreducible component of $U$ passing through $u$.
\end{enumerate}
\end{lemma}

\begin{proof}
Parts (3) and (4) follow from parts (1) and (2) via
Properties, Lemma \ref{properties-lemma-number-of-branches-1}.

\medskip\noindent
Proof of (1). Let $\Spec(A)$ be an affine open neighbourhood
of $x$ and let $\mathfrak p \subset A$ be the prime ideal
corresponding to $x$. We may replace $X$ by $\Spec(A)$ and
it suffices to consider affine elementary \'etale neighbourhoods
$(U, u)$ in the supremum as they form a cofinal subsystem.
Recall that the henselization $A_\mathfrak p^h$
is the colimit of the rings $B_\mathfrak q$ over the category
of pairs $(B, \mathfrak q)$ where $B$ is an \'etale $A$-algebra
and $\mathfrak q$ is a prime lying over $\mathfrak p$ with
$\kappa(\mathfrak q) = \kappa(\mathfrak p)$, see
Algebra, Lemma \ref{algebra-lemma-henselization-different}.
These pairs $(B, \mathfrak q)$ correspond exactly to
the affine elementary \'etale neighbourhoods $(U, u)$
by the correspondence between rings and affine schemes.
Observe that irreducible components of $\Spec(B)$
passing through $\mathfrak q$ are exactly the minimal
prime ideals of $B_\mathfrak q$. The number of minimal
primes of $A_\mathfrak p^h$ is the number of branches
of $X$ at $x$ by Properties, Definition
\ref{properties-definition-number-of-branches}.
Observe that the transition
maps $B_\mathfrak q \to B'_{\mathfrak q'}$ in the system
are all flat. Since a flat local ring map is faithfully flat
(Algebra, Lemma \ref{algebra-lemma-local-flat-ff})
we see that the lemma follows
from Lemma \ref{lemma-nr-minimal-primes}.

\medskip\noindent
Proof of (2). The proof is the same as the proof of (1), except that we use
Algebra, Lemma \ref{algebra-lemma-strict-henselization-different}.
There is a tiny difference: given a separable algebraic closure
$\kappa^{sep}$ of $\kappa(x)$ for every \'etale neighbourhood
$(U, u)$ we can choose a $\kappa(x)$-embedding
$\phi : \kappa(u) \to \kappa^{sep}$
because $\kappa(u)/\kappa(x)$ is finite separable
(Morphisms, Lemma \ref{morphisms-lemma-etale-at-point}).
Hence we can look at the supremum over all triples
$(U, u, \phi)$ where $(U, u) \to (X, x)$ is an affine
\'etale neighbourhood and $\phi : \kappa(u) \to \kappa^{sep}$
is a $\kappa(x)$-embedding. These triples correspond
exactly to the triples in
Algebra, Lemma \ref{algebra-lemma-strict-henselization-different}
and the rest of the proof is exactly the same.
\end{proof}

\noindent
We will need a relative variant of the lemma above.

\begin{lemma}
\label{lemma-nr-branches-fibre}
Let $X \to S$ be a morphism of schemes and $x \in X$ a point with image $s$.
Then
\begin{enumerate}
\item the number of branches of the fibre $X_s$ at $x$ is equal to
the supremum of the number of irreducible components of the fibre $U_s$
passing through $u$ taken over elementary \'etale neighbourhoods
$(U, u) \to (X, x)$,
\item the number of geometric branches of the fibre $X_s$ at $x$ is equal to
the supremum of the number of irreducible components of the fibre $U_s$
passing through $u$ taken over \'etale neighbourhoods
$(U, u) \to (X, x)$,
\item the fibre $X_s$ is unibranch at $x$ if and only if for every
elementary \'etale neighbourhood $(U, u) \to (X, x)$ there is
exactly one irreducible component of the fibre $U_s$ passing through $u$, and
\item $X$ is geometrically unibranch at $x$ if and only if for every
\'etale neighbourhood $(U, u) \to (X, x)$ there
is exactly one irreducible component of $U_s$ passing through $u$.
\end{enumerate}
\end{lemma}

\begin{proof}
Combine Lemmas \ref{lemma-nr-branches} and
\ref{lemma-lift-etale-neighbourhood-fibre}.
\end{proof}

\begin{lemma}
\label{lemma-number-of-branches-and-smooth}
Let $X \to S$ be a smooth morphism of schemes.
Let $x \in X$ with image $s \in S$.
Then
\begin{enumerate}
\item The number of geometric branches of $X$ at $x$
is equal to the number of geometric branches of $S$ at $s$.
\item If $\kappa(x)/\kappa(s)$ is a purely inseparable\footnote{In fact,
it would suffice if $\kappa(x)$ is geometrically irreducible over
$\kappa(s)$. If we ever need this we will add a detailed proof.}
extension of fields, then number of branches of $X$ at $x$
is equal to the number of branches of $S$ at $s$.
\end{enumerate}
\end{lemma}

\begin{proof}
Follows immediately from More on Algebra, Lemma
\ref{more-algebra-lemma-invariance-number-branches-smooth}
and the definitions.
\end{proof}




\section{Unramified and \'etale morphisms}
\label{section-unramified-is-etale}

\noindent
Sometimes unramified morphisms are automatically \'etale.

\begin{lemma}
\label{lemma-unramified-dominant-unibranch-is-etale}
Let $f : X \to Y$ be a morphism of schemes. Let $x \in X$ with
image $y \in Y$. Assume
\begin{enumerate}
\item $Y$ is integral and geometrically unibranch at $y$,
\item $f$ is locally of finite type,
\item there is a specialization $x' \leadsto x$ such that $f(x')$
is the generic point of $Y$,
\item $f$ is unramified at $x$.
\end{enumerate}
Then $f$ is \'etale at $x$.
\end{lemma}

\begin{proof}
We may replace $X$ and $Y$ by suitable affine open neighbourhoods
of $x$ and $y$. Then $Y$ is the spectrum of a domain $A$ and
$X$ is the spectrum of a finite type $A$-algebra $B$.
Let $\mathfrak q \subset B$ be the prime ideal corresponding
to $x$ and $\mathfrak p \subset A$ the prime ideal corresponding to $y$.
The local ring $A_\mathfrak p = \mathcal{O}_{Y, y}$ is geometrically unibranch.
The ring map $A \to B$ is unramified at $\mathfrak q$.
Also, the point $x'$ in (3) corresponds to a prime ideal
$\mathfrak q' \subset \mathfrak q$ such that $A \cap \mathfrak q' = (0)$.
It follows that $A_\mathfrak p \to B_\mathfrak q$ is injective.
We conclude by
More on Algebra, Lemma
\ref{more-algebra-lemma-local-unramified-extension-unibranch-domain-is-etale}.
\end{proof}

\begin{lemma}
\label{lemma-global-unramified-dominant-unibranch-is-etale}
\begin{reference}
\cite[Expose I, Corollary 9.11]{SGA1}
\end{reference}
Let $f : X \to Y$ be a morphism of schemes. Assume
\begin{enumerate}
\item $Y$ is integral and geometrically unibranch,
\item at least one irreducible component of $X$ dominates $Y$,
\item $f$ is unramified, and
\item $X$ is connected.
\end{enumerate}
Then $f$ is \'etale and $X$ is irreducible.
\end{lemma}

\begin{proof}
Let $X' \subset X$ be the irreducible component which dominates $Y$.
This means that the generic point of $X'$ maps to the generic point of $Y$
(see for example Morphisms, Lemma
\ref{morphisms-lemma-dominant-finite-number-irreducible-components}).
By Lemma \ref{lemma-unramified-dominant-unibranch-is-etale}
we see that $f$ is \'etale at every point of $X'$. In particular,
the open subscheme $U \subset X$ where $f$ is \'etale contains $X'$.
Note that every quasi-compact open of $U$ has finitely many irreducible
components, see
Descent, Lemma \ref{descent-lemma-locally-finite-nr-irred-local-fppf}.
On the other hand since $Y$ is geometrically unibranch and $U$ is \'etale
over $Y$, the scheme $U$ is geometrically unibranch. In particular, through
every point of $U$ there passes at most one irreducible component.
A simple topological argument now shows that $X' \subset U$
is both open and closed. Then of course $X'$ is open and closed in $X$ and by
connectedness we find $X = U = X'$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-weird-permanence-etale}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of schemes.
Let $x \in X$ with image $y \in Y$. Assume
\begin{enumerate}
\item $Y$ is integral and geometrically unibranch at $y$,
\item $f$ is locally of finite type,
\item $g \circ f$ is \'etale at $x$,
\item there is a specialization $x' \leadsto x$ such that $f(x')$
is the generic point of $Y$.
\end{enumerate}
Then $f$ is \'etale at $x$ and $g$ is \'etale at $y$.
\end{lemma}

\begin{proof}
The morphism $f$ is unramified at $x$ by Morphisms, Lemmas
\ref{morphisms-lemma-unramified-permanence}
and \ref{morphisms-lemma-etale-smooth-unramified}.
Hence $f$ is \'etale at $x$ by
Lemma \ref{lemma-unramified-dominant-unibranch-is-etale}.
Then by \'etale descent we see that $g$ is \'etale at $y$, see
for example Descent, Lemma
\ref{descent-lemma-syntomic-smooth-etale-permanence}.
\end{proof}

\begin{lemma}
\label{lemma-global-weird-permanence-etale}
Let $f : X \to Y$ and $g : Y \to Z$ be morphisms of schemes.
Assume
\begin{enumerate}
\item $Y$ is integral and geometrically unibranch,
\item $f$ is locally of finite type,
\item $g \circ f$ is \'etale,
\item every irreducible component of $X$ dominates $Y$.
\end{enumerate}
Then $f$ is \'etale and $g$ is \'etale at every point in
the image of $f$.
\end{lemma}

\begin{proof}
Immediate from the pointwise version
Lemma \ref{lemma-weird-permanence-etale}.
\end{proof}










\section{Slicing smooth morphisms}
\label{section-etale-over-smooth}

\noindent
In this section we explain a result that roughly states that
smooth coverings of a scheme $S$ can be refined by \'etale coverings.
The technique to prove this relies on a slicing argument.

\begin{lemma}
\label{lemma-slice-smooth-given-element}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Let $h \in \mathfrak m_x \subset \mathcal{O}_{X, x}$.
Assume
\begin{enumerate}
\item $f$ is smooth at $x$, and
\item the image $\text{d}\overline{h}$ of $\text{d}h$ in
$$
\Omega_{X_s/s, x} \otimes_{\mathcal{O}_{X_s, x}} \kappa(x) =
\Omega_{X/S, x} \otimes_{\mathcal{O}_{X, x}} \kappa(x)
$$
is nonzero.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
such that $h$ comes from $h \in \Gamma(U, \mathcal{O}_U)$ and such
that $D = V(h)$ is an effective Cartier divisor in $U$ with $x \in D$ and
$D \to S$ smooth.
\end{lemma}

\begin{proof}
As $f$ is smooth at $x$ we may assume, after replacing $X$ by an open
neighbourhood of $x$ that $f$ is smooth. In particular we see that
$f$ is flat and locally of finite presentation. By
Lemma \ref{lemma-slice-given-element}
we already know there exists an open neighbourhood $U \subset X$ of $x$
such that $h$ comes from $h \in \Gamma(U, \mathcal{O}_U)$ and such
that $D = V(h)$ is an effective Cartier divisor in $U$ with $x \in D$ and
$D \to S$ flat and of finite presentation. By
Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion}
we have a short exact sequence
$$
\mathcal{C}_{D/U} \to i^*\Omega_{U/S} \to \Omega_{D/S} \to 0
$$
where $i : D \to U$ is the closed immersion and $\mathcal{C}_{D/U}$
is the conormal sheaf of $D$ in $U$. As $D$ is an effective Cartier
divisor cut out by $h \in \Gamma(U, \mathcal{O}_U)$ we see that
$\mathcal{C}_{D/U} = h \cdot \mathcal{O}_S$. Since $U \to S$ is smooth
the sheaf $\Omega_{U/S}$ is finite locally free, hence its pullback
$i^*\Omega_{U/S}$ is finite locally free also. The first arrow of
the sequence maps the free generator $h$ to the section $\text{d}h|_D$
of $i^*\Omega_{U/S}$ which has nonzero value in the fibre
$\Omega_{U/S, x} \otimes \kappa(x)$ by assumption. By right exactness
of $\otimes \kappa(x)$ we conclude that
$$
\dim_{\kappa(x)} \left( \Omega_{D/S, x} \otimes \kappa(x) \right)
=
\dim_{\kappa(x)} \left( \Omega_{U/S, x} \otimes \kappa(x) \right) - 1.
$$
By
Morphisms, Lemma \ref{morphisms-lemma-smooth-at-point}
we see that $\Omega_{U/S, x} \otimes \kappa(x)$ can be generated by
at most $\dim_x(U_s)$ elements. By the displayed formula we see that
$\Omega_{D/S, x} \otimes \kappa(x)$ can be generated by at most
$\dim_x(U_s) - 1$ elements. Note that
$\dim_x(D_s) = \dim_x(U_s) - 1$ for example because
$\dim(\mathcal{O}_{D_s, x}) = \dim(\mathcal{O}_{U_s, x}) - 1$ by
Algebra, Lemma \ref{algebra-lemma-one-equation}
(also $D_s \subset U_s$ is effective Cartier, see
Divisors, Lemma \ref{divisors-lemma-relative-Cartier})
and then using
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point}.
Thus we conclude that $\Omega_{D/S, x} \otimes \kappa(x)$ can be generated
by at most $\dim_x(D_s)$ elements and we conclude that $D \to S$
is smooth at $x$ by
Morphisms, Lemma \ref{morphisms-lemma-smooth-at-point}
again. After shrinking $U$ we get that $D \to S$ is smooth and we win.
\end{proof}

\begin{lemma}
\label{lemma-slice-smooth-once}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Assume
\begin{enumerate}
\item $f$ is smooth at $x$, and
\item the map
$$
\Omega_{X_s/s, x} \otimes_{\mathcal{O}_{X_s, x}} \kappa(x)
\longrightarrow
\Omega_{\kappa(x)/\kappa(s)}
$$
has a nonzero kernel.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
and an effective Cartier divisor $D \subset U$ containing $x$ such that
$D \to S$ is smooth.
\end{lemma}

\begin{proof}
Write $k = \kappa(s)$ and $R = \mathcal{O}_{X_s, x}$.
Denote $\mathfrak m$ the maximal ideal of $R$ and
$\kappa = R/\mathfrak m$ so that $\kappa = \kappa(x)$.
As formation of modules of differentials commutes with localization (see
Algebra, Lemma \ref{algebra-lemma-differentials-localize})
we have $\Omega_{X_s/s, x} = \Omega_{R/k}$. By
Algebra, Lemma \ref{algebra-lemma-differential-seq}
there is an exact sequence
$$
\mathfrak m/\mathfrak m^2 \xrightarrow{\text{d}}
\Omega_{R/k} \otimes_R \kappa \to
\Omega_{\kappa/k} \to 0.
$$
Hence if (2) holds, there exists an element $\overline{h} \in \mathfrak m$
such that $\text{d}\overline{h}$ is nonzero. Choose a lift
$h \in \mathcal{O}_{X, x}$ of $\overline{h}$ and apply
Lemma \ref{lemma-slice-smooth-given-element}.
\end{proof}

\begin{remark}
\label{remark-necessary-condition-slice-smooth}
The second condition in
Lemma \ref{lemma-slice-smooth-once}
is necessary even if $x$ is a closed point of a positive
dimensional fibre. An example is the following: Let $k$ be a field
of characteristic $p > 0$ which is imperfect. Let $a \in k$ be an
element which is not a $p$th power. Let
$\mathfrak m = (x, y^p - a) \subset k[x, y]$. This corresponds to a closed
point $w$ of $X = \mathbf{A}^2_k$. Set $S = \mathbf{A}^1_k$ and
let $f : X \to S$ be the morphism corresponding to $k[x] \to k[x, y]$.
Then there does not exist any commutative diagram
$$
\xymatrix{
S' \ar[rr]_h \ar[rd]_g & & X \ar[ld]^f \\
& S
}
$$
with $g$ \'etale and $w$ in the image of $h$. This is clear as the residue
field extension $\kappa(w)/\kappa(f(w))$ is purely inseparable,
but for any $s' \in S'$ with $g(s') = f(w)$ the extension
$\kappa(s')/\kappa(f(w))$ would be separable.
\end{remark}

\noindent
If you assume the residue field extension is separable then the
phenomenon of
Remark \ref{remark-necessary-condition-slice-smooth}
does not happen. Here is the precise result.

\begin{lemma}
\label{lemma-slice-smooth-once-separable-residue-field-extension}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Assume
\begin{enumerate}
\item $f$ is smooth at $x$,
\item the residue field extension $\kappa(x)/\kappa(s)$
is separable, and
\item $x$ is not a generic point of $X_s$.
\end{enumerate}
Then there exists an affine open neighbourhood $U \subset X$ of $x$
and an effective Cartier divisor $D \subset U$ containing $x$ such that
$D \to S$ is smooth.
\end{lemma}

\begin{proof}
Write $k = \kappa(s)$ and $R = \mathcal{O}_{X_s, x}$.
Denote $\mathfrak m$ the maximal ideal of $R$ and
$\kappa = R/\mathfrak m$ so that $\kappa = \kappa(x)$.
As formation of modules of differentials commutes with localization (see
Algebra, Lemma \ref{algebra-lemma-differentials-localize})
we have $\Omega_{X_s/s, x} = \Omega_{R/k}$. By assumption (2) and
Algebra, Lemma \ref{algebra-lemma-computation-differential}
the map
$$
\text{d} :
\mathfrak m/\mathfrak m^2
\longrightarrow
\Omega_{R/k} \otimes_R \kappa(\mathfrak m)
$$
is injective. Assumption (3) implies that
$\mathfrak m/\mathfrak m^2 \not = 0$.
Thus there exists an element $\overline{h} \in \mathfrak m$
such that $\text{d}\overline{h}$ is nonzero. Choose a lift
$h \in \mathcal{O}_{X, x}$ of $\overline{h}$ and apply
Lemma \ref{lemma-slice-smooth-given-element}.
\end{proof}

\noindent
The subscheme $Z$ constructed in the following lemma is really a complete
intersection in an affine open neighbourhood of $x$. If we ever need this
we will explicitly formulate a separate lemma stating this fact.

\begin{lemma}
\label{lemma-slice-smooth}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ be a point with image $s \in S$.
Assume
\begin{enumerate}
\item $f$ is smooth at $x$, and
\item $x$ is a closed point of $X_s$ and $\kappa(s) \subset \kappa(x)$
is separable.
\end{enumerate}
Then there exists an immersion $Z \to X$ containing $x$ such that
\begin{enumerate}
\item $Z \to S$ is \'etale, and
\item $Z_s = \{x\}$ set theoretically.
\end{enumerate}
\end{lemma}

\begin{proof}
We may and do replace $S$ by an affine open neighbourhood of $s$.
We may and do replace $X$ by an affine open neighbourhood of $x$
such that $X \to S$ is smooth.
We will prove the lemma for smooth morphisms of affines
by induction on $d = \dim_x(X_s)$.

\medskip\noindent
The case $d = 0$. In this case we show that we may take $Z$ to be
an open neighbourhood of $x$. Namely, if $d = 0$, then $X \to S$
is quasi-finite at $x$, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-rel-dimension-0}.
Hence there exists an affine open neighbourhood $U \subset X$ such
that $U \to S$ is quasi-finite, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open}.
Thus after replacing $X$ by $U$ we see that
$X$ is quasi-finite and smooth over $S$, hence
smooth of relative dimension $0$ over $S$, hence
\'etale over $S$. Moreover, the fibre $X_s$ is a finite
discrete set. Hence after replacing $X$ by a further affine open neighbourhood
of $X$ we see that $f^{-1}(\{s\}) = \{x\}$ (because the topology
on $X_s$ is induced from the topology on $X$, see
Schemes, Lemma \ref{schemes-lemma-fibre-topological}).
This proves the lemma in this case.

\medskip\noindent
Next, assume $d > 0$. Note that because $x$ is a closed point of its
fibre the extension $\kappa(x)/\kappa(s)$ is finite (by the
Hilbert Nullstellensatz, see
Morphisms, Lemma \ref{morphisms-lemma-closed-point-fibre-locally-finite-type}).
Thus we see $\Omega_{\kappa(x)/\kappa(s)} = 0$ as this holds for
algebraic separable field extensions.
Thus we may apply
Lemma \ref{lemma-slice-smooth-once}
to find a diagram
$$
\xymatrix{
D \ar[r] \ar[rrd] & U \ar[r] \ar[rd] & X \ar[d] \\
& & S
}
$$
with $x \in D$. Note that
$\dim_x(D_s) = \dim_x(X_s) - 1$ for example because
$\dim(\mathcal{O}_{D_s, x}) = \dim(\mathcal{O}_{X_s, x}) - 1$ by
Algebra, Lemma \ref{algebra-lemma-one-equation}
(also $D_s \subset X_s$ is effective Cartier, see
Divisors, Lemma \ref{divisors-lemma-relative-Cartier})
and then using
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point}.
Thus the morphism $D \to S$ is smooth with
$\dim_x(D_s) = \dim_x(X_s) - 1 = d - 1$. By induction hypothesis
we can find an immersion $Z \to D$ as desired, which finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-etale-nbhd-dominates-smooth}
Let $f : X \to S$ be a smooth morphism of schemes.
Let $s \in S$ be a point in the image of $f$.
Then there exists an \'etale neighbourhood $(S', s') \to (S, s)$
and a $S$-morphism $S' \to X$.
\end{lemma}

\begin{proof}[First proof of Lemma \ref{lemma-etale-nbhd-dominates-smooth}]
By assumption $X_s \not = \emptyset$. By
Varieties, Lemma \ref{varieties-lemma-smooth-separable-closed-points-dense}
there exists a closed point $x \in X_s$ such that $\kappa(x)$
is a finite separable field extension of $\kappa(s)$.
Hence by
Lemma \ref{lemma-slice-smooth}
there exists an immersion $Z \to X$ such that $Z \to S$ is \'etale and such
that $x \in Z$. Take $(S' , s') = (Z, x)$.
\end{proof}

\begin{proof}[Second proof of Lemma \ref{lemma-etale-nbhd-dominates-smooth}]
Pick a point $x \in X$ with $f(x) = s$.
Choose a diagram
$$
\xymatrix{
X \ar[d] & U \ar[l] \ar[d] \ar[r]_-\pi & \mathbf{A}^d_V \ar[ld] \\
S & V \ar[l]
}
$$
with $\pi$ \'etale, $x \in U$ and $V = \Spec(R)$ affine, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-etale-over-affine-space}.
In particular $s \in V$. The morphism
$\pi : U \to \mathbf{A}^d_V$ is open, see
Morphisms, Lemma \ref{morphisms-lemma-etale-open}.
Thus $W = \pi(U) \cap \mathbf{A}^d_s$ is a nonempty open subset of
$\mathbf{A}^d_s$. Let $w \in W$ be a point with $\kappa(s) \subset \kappa(w)$
finite separable, see
Varieties, Lemma \ref{varieties-lemma-affine-space-over-field}.
By
Algebra, Lemma \ref{algebra-lemma-dim-affine-space}
there exist $d$ elements
$\overline{f}_1, \ldots, \overline{f}_d \in \kappa(s)[x_1, \ldots, x_d]$
which generate the maximal ideal corresponding to $w$ in
$\kappa(s)[x_1, \ldots, x_d]$.
After replacing $R$ by a principal localization
we may assume there are $f_1, \ldots, f_d \in R[x_1, \ldots, x_d]$
which map to
$\overline{f}_1, \ldots, \overline{f}_d \in \kappa(s)[x_1, \ldots, x_d]$.
Consider the $R$-algebra
$$
R' = R[x_1, \ldots, x_d]/(f_1, \ldots, f_d)
$$
and set $S' = \Spec(R')$. By construction we have a closed
immersion $j : S' \to \mathbf{A}^d_V$ over $V$.
By construction the fibre of $S' \to V$ over $s$ is a single
point $s'$ whose residue field is finite separable over $\kappa(s)$.
Let $\mathfrak q' \subset R'$ be the corresponding prime. By
Algebra, Lemma \ref{algebra-lemma-localize-relative-complete-intersection}
we see that $(R')_g$ is a relative global complete intersection over $R$
for some $g \in R'$, $g \not \in \mathfrak q$.
Thus $S' \to V$ is flat and of finite presentation in a
neighbourhood of $s'$, see
Algebra, Lemma \ref{algebra-lemma-relative-global-complete-intersection}.
By construction the scheme theoretic fibre
of $S' \to V$ over $s$ is $\Spec(\kappa(s'))$. Hence it follows from
Morphisms, Lemma \ref{morphisms-lemma-etale-at-point}
that $S' \to S$ is \'etale at $s'$. Set
$$
S'' = U \times_{\pi, \mathbf{A}^d_V, j} S'.
$$
By construction there exists a point $s'' \in S''$ which maps to
$s'$ via the projection $p : S'' \to S'$. Note that $p$ is \'etale
as the base change of the \'etale morphism $\pi$, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-etale}.
Choose a small affine neighbourhood $S''' \subset S''$ of $s''$
which maps into the nonempty open neighbourhood of $s' \in S'$
where the morphism $S' \to S$ is \'etale. Then the \'etale neighbourhood
$(S''', s'') \to (S, s)$ is a solution to the problem posed by the lemma.
\end{proof}

\noindent
The following lemma shows that sheaves for the smooth topology are
the same thing as sheaves for the \'etale topology.

\begin{lemma}
\label{lemma-etale-dominates-smooth}
Let $S$ be a scheme. Let $\mathcal{U} = \{S_i \to S\}_{i \in I}$ be a smooth
covering of $S$, see
Topologies, Definition \ref{topologies-definition-smooth-covering}.
Then there exists an \'etale covering $\mathcal{V} = \{T_j \to S\}_{j \in J}$
(see
Topologies, Definition \ref{topologies-definition-etale-covering})
which refines (see
Sites, Definition \ref{sites-definition-morphism-coverings})
$\mathcal{U}$.
\end{lemma}

\begin{proof}
For every $s \in S$ there exists an $i \in I$ such that $s$ is in
the image of $S_i \to S$. By
Lemma \ref{lemma-etale-nbhd-dominates-smooth}
we can find an \'etale morphism $g_s : T_s \to S$ such that $s \in g_s(T_s)$
and such that $g_s$ factors through $S_i \to S$. Hence
$\{T_s \to S\}$ is an \'etale covering of $S$ that refines $\mathcal{U}$.
\end{proof}

\begin{lemma}
\label{lemma-cover-smooth-by-special}
Let $f : X \to S$ be a smooth morphism of schemes. Then there exists an
\'etale covering $\{U_i \to X\}_{i \in I}$ such that $U_i \to S$
factors as $U_i \to V_i \to S$ where $V_i \to S$ is \'etale and
$U_i \to V_i$ is a smooth morphism of affine schemes, which
has a section, and has geometrically connected fibres.
\end{lemma}

\begin{proof}
Let $s \in S$. By
Varieties, Lemma \ref{varieties-lemma-smooth-separable-closed-points-dense}
the set of closed points $x \in X_s$ such that $\kappa(x)/\kappa(s)$
is separable is dense in $X_s$. Thus it suffices to construct an
\'etale morphism $U \to X$ with $x$ in the image
such that $U \to S$ factors in the manner described in the lemma.
To do this, choose an immersion $Z \to X$ passing through $x$
such that $Z \to S$ is \'etale (Lemma \ref{lemma-slice-smooth}).
After replacing $S$ by $Z$ and $X$ by $Z \times_S X$
we see that we may assume $X \to S$ has a section $\sigma : S \to X$
with $\sigma(s) = x$. Then we can first replace $S$ by an affine
open neighbourhood of $s$ and next replace $X$ by an affine open
neighbourhood of $x$. Then finally, we consider the subset
$X^0 \subset X$ of Section \ref{section-connected-components}.
By Lemmas \ref{lemma-connected-along-section-open} and
\ref{lemma-connected-along-section-locally-constructible}
this is a retrocompact open subscheme containing $\sigma$
such that the fibres $X^0 \to S$ are geometrically connected.
If $X^0$ is not affine, then we choose an affine open $U \subset X^0$
containing $x$. Since $X^0 \to S$ is smooth, the image of $U$
is open. Choose an affine open neighbourhood $V \subset S$ of $s$
contained in $\sigma^{-1}(U)$ and in the image of $U \to S$.
Finally, the reader sees that $U \cap f^{-1}(V) \to V$
has all the desired properties. For example $U \cap f^{-1}(V)$
is equal to $U \times_S V$ is affine as a fibre product of affine
schemes. Also, the geometric fibres of $U \cap f^{-1}(V) \to V$ are
nonempty open subschemes of the irreducible fibres of $X^0 \to S$
and hence connected. Some details omitted.
\end{proof}

\noindent
The following lemma should probably be somewhere else.

\begin{lemma}
\label{lemma-etale-local-structure}
Let $S$ be a scheme. Let $Y \to X$ be a closed immersion of schemes
smooth over $S$. For every $y \in Y$ there exist integers
$0 \leq m, n$ and a commutative diagram
$$
\xymatrix{
Y \ar[d] &
V \ar[l] \ar[d] \ar[r] &
\mathbf{A}^m_S
\ar[d]^{(a_1, \ldots, a_m) \mapsto (a_1, \ldots, a_m, 0 \ldots, 0)} \\
X &
U \ar[l] \ar[r]^-\pi &
\mathbf{A}^{m + n}_S
}
$$
where $U \subset X$ is open, $V = Y \cap U$,
$\pi$ is \'etale, $V = \pi^{-1}(\mathbf{A}^m_S)$, and $y \in V$.
\end{lemma}

\begin{proof}
The question is local on $X$ hence we may replace $X$ by
an open neighbourhood of $y$. Since $Y \to X$ is a regular immersion
by Divisors, Lemma
\ref{divisors-lemma-immersion-smooth-into-smooth-regular-immersion}
we may assume $X = \Spec(A)$ is affine and there exists a regular sequence
$f_1, \ldots, f_n \in A$ such that $Y = V(f_1, \ldots, f_n)$.
After shrinking $X$ (and hence $Y$) further
we may assume there exists an \'etale morphism $Y \to \mathbf{A}^m_S$, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-etale-over-affine-space}.
Let $\overline{g}_1, \ldots, \overline{g}_m$ in $\mathcal{O}_Y(Y)$
be the coordinate functions of this \'etale morphism.
Choose lifts $g_1, \ldots, g_m \in A$ of these functions
and consider the morphism
$$
(g_1, \ldots, g_m, f_1, \ldots, f_n) :
X
\longrightarrow
\mathbf{A}^{m + n}_S
$$
over $S$. This is a morphism of schemes locally of finite presentation
over $S$ and hence is locally of finite presentation
(Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}).
The restriction of this morphism to
$\mathbf{A}^m_S \subset \mathbf{A}^{m + n}_S$
is \'etale by construction. Thus, in order to show that
$X \to \mathbf{A}^{m + n}_S$ is \'etale at $y$
it suffices to show that $X \to \mathbf{A}^{m + n}_S$ is flat at $y$,
see Morphisms, Lemma \ref{morphisms-lemma-etale-at-point}.
Let $s \in S$ be the image of $y$. It suffices to check that
$X_s \to \mathbf{A}^{m + n}_s$ is flat at $y$, see
Theorem \ref{theorem-criterion-flatness-fibre}.
Let $z \in \mathbf{A}^{m + n}_s$ be the image of $y$.
The local ring map
$$
\mathcal{O}_{\mathbf{A}^{m + n}_s, z}
\longrightarrow
\mathcal{O}_{X_s, y}
$$
is flat by Algebra, Lemma \ref{algebra-lemma-CM-over-regular-flat}.
Namely, schemes smooth over fields are regular and regular rings
are Cohen-Macaulay, see Varieties, Lemma \ref{varieties-lemma-smooth-regular}
and Algebra, Lemma \ref{algebra-lemma-regular-ring-CM}.
Thus both source and target are regular local rings (and hence CM).
The source and target have the same dimension: namely, we have
$\dim(\mathcal{O}_{Y_s, y}) = \dim(\mathcal{O}_{\mathbf{A}^m_s, z})$
by More on Algebra, Lemma \ref{more-algebra-lemma-dimension-etale-extension},
we have $\dim(\mathcal{O}_{\mathbf{A}^{m + n}_s, z}) = n +
\dim(\mathcal{O}_{\mathbf{A}^m_s, z})$, and we have
$\dim(\mathcal{O}_{X_s, y}) = n + \dim(\mathcal{O}_{Y_s, y})$
because $\mathcal{O}_{Y_s, y}$ is the quotient of
$\mathcal{O}_{X_s, y}$ by the regular sequence $f_1, \ldots, f_n$
of length $n$ (see
Divisors, Remark \ref{divisors-remark-relative-regular-immersion-elements}).
Finally, the fibre ring of the displayed arrow is finite over $\kappa(z)$
since $Y_s \to \mathbf{A}^m_s$ is \'etale at $y$.
This finishes the proof.
\end{proof}











\section{\'Etale neighbourhoods and Artin approximation}
\label{section-etale-nbhds-artin}

\noindent
In this section we prove results of the form: if two
pointed schemes have isomorphic complete local rings, then
they have isomorphic \'etale neighbourhoods. We will rely
on Popescu's theorem, see
Smoothing Ring Maps, Theorem \ref{smoothing-theorem-popescu}.

\begin{lemma}
\label{lemma-map-approximation}
Let $S$ be a locally Noetherian scheme. Let $X$, $Y$ be
schemes locally of finite
type over $S$. Let $x \in X$ and $y \in Y$ be points lying over the
same point $s \in S$. Assume $\mathcal{O}_{S, s}$ is a G-ring.
Assume further we are given a local $\mathcal{O}_{S, s}$-algebra map
$$
\varphi : \mathcal{O}_{Y, y} \longrightarrow \mathcal{O}_{X, x}^\wedge
$$
For every $N \geq 1$
there exists an elementary \'etale neighbourhood
$(U, u) \to (X, x)$ and an $S$-morphism
$f : U \to Y$ mapping $u$ to $y$ such that the diagram
$$
\xymatrix{
\mathcal{O}_{X, x}^\wedge \ar[r] &
\mathcal{O}_{U, u}^\wedge \\
\mathcal{O}_{Y, y} \ar[r]^{f^\sharp_u} \ar[u]^\varphi &
\mathcal{O}_{U, u} \ar[u]
}
$$
commutes modulo $\mathfrak m_u^N$.
\end{lemma}

\begin{proof}
The question is local on $X$ hence we may assume $X$, $Y$, $S$ are affine.
Say $S = \Spec(R)$, $X = \Spec(A)$, $Y = \Spec(B)$.
Write $B = R[x_1, \ldots, x_n]/(f_1, \ldots, f_m)$.
Let $\mathfrak p \subset A$ be the prime ideal corresponding to $x$.
The local ring $\mathcal{O}_{X, x} = A_\mathfrak p$ is a G-ring by
More on Algebra, Proposition
\ref{more-algebra-proposition-finite-type-over-G-ring}.
The map $\varphi$ is a map
$$
B_\mathfrak q^\wedge \longrightarrow A_\mathfrak p^\wedge
$$
where $\mathfrak q \subset B$ is the prime corresponding to $y$.
Let $a_1, \ldots, a_n \in A_\mathfrak p^\wedge$ be the images
of $x_1, \ldots, x_n$ via
$R[x_1, \ldots, x_n] \to B \to B_\mathfrak q^\wedge \to A_\mathfrak p^\wedge$.
Then we can apply Smoothing Ring Maps, Lemma
\ref{smoothing-lemma-approximation-property-variant}
to get an \'etale ring map $A \to A'$ and a prime ideal
$\mathfrak p' \subset A'$ and $b_1, \ldots, b_n \in A'$ such that
$\kappa(\mathfrak p) = \kappa(\mathfrak p')$,
$a_i - b_i \in (\mathfrak p')^N(A'_{\mathfrak p'})^\wedge$, and
$f_j(b_1, \ldots, b_n) = 0$ for $j = 1, \ldots, n$.
This determines an $R$-algebra map $B \to A'$ by sending the
class of $x_i$ to $b_i \in A'$. This finishes the proof
by taking $U = \Spec(A') \to \Spec(B)$ as the morphism $f$
and $u = \mathfrak p'$.
\end{proof}

\begin{lemma}
\label{lemma-isomorphism-approximation}
Let $S$ be a locally Noetherian scheme. Let $X$, $Y$ be
schemes locally of finite
type over $S$. Let $x \in X$ and $y \in Y$ be points lying over the
same point $s \in S$. Assume $\mathcal{O}_{S, s}$ is a G-ring.
Assume we have an $\mathcal{O}_{S, s}$-algebra isomorphism
$$
\varphi : \mathcal{O}_{Y, y}^\wedge \longrightarrow \mathcal{O}_{X, x}^\wedge
$$
between the complete local rings. Then for every $N \geq 1$
there exists morphisms
$$
(X, x) \leftarrow (U, u) \rightarrow (Y, y)
$$
of pointed schemes over $S$ such that both arrows define elementary
\'etale neighbourhoods and such that the diagram
$$
\xymatrix{
& \mathcal{O}_{U, u}^\wedge \\
\mathcal{O}_{Y, y}^\wedge \ar[rr]^\varphi \ar[ru] & &
\mathcal{O}_{X, x}^\wedge \ar[lu]
}
$$
commutes modulo $\mathfrak m_u^N$.
\end{lemma}

\begin{proof}
We may assume $N \geq 2$. Apply Lemma \ref{lemma-map-approximation} to get
$(U, u) \to (X, x)$ and $f : (U, u) \to (Y, y)$.
We claim that $f$ is \'etale at $u$ which will finish the proof.
In fact, we will show that the induced map
$\mathcal{O}_{Y, y}^\wedge \to \mathcal{O}_{U, u}^\wedge$
is an isomorphism. Having proved this,
Lemma \ref{lemma-lifting-along-artinian-at-point}
will show that $f$ is smooth at $u$ and of course
$f$ is unramified at $u$ as well, so
Morphisms, Lemma \ref{morphisms-lemma-etale-smooth-unramified}
tells us $f$ is \'etale at $u$.
For a local ring $(R, \mathfrak m)$ we set
$\text{Gr}_\mathfrak m(R) =
\bigoplus_{n \geq 0} \mathfrak m^n/\mathfrak m^{n + 1}$.
To prove the claim we look at the induced diagram
of graded rings
$$
\xymatrix{
& \text{Gr}_{\mathfrak m_u}(\mathcal{O}_{U, u}) \\
\text{Gr}_{\mathfrak m_y}(\mathcal{O}_{Y, y}) \ar[rr]^\varphi \ar[ru] & &
\text{Gr}_{\mathfrak m_x}(\mathcal{O}_{X, x}) \ar[lu]
}
$$
Since $N \geq 2$ this diagram is actually commutative as the
displayed graded algebras are generated in degree $1$!
By assumption the lower arrow is an isomorphism.
By More on Algebra, Lemma \ref{more-algebra-lemma-flat-unramified}
(for example) the map
$\mathcal{O}_{X, x}^\wedge \to \mathcal{O}_{U, u}^\wedge$
is an isomorphism and hence the north-west arrow
in the diagram is an isomorphism. We conclude that
$f$ induces an isomorphism
$\text{Gr}_{\mathfrak m_x}(\mathcal{O}_{X, x}) \to
\text{Gr}_{\mathfrak m_y}(\mathcal{O}_{U, u})$.
Using induction and the short exact sequences
$$
0 \to \text{Gr}^n_{\mathfrak m}(R) \to R/\mathfrak m^{n + 1} \to
R/\mathfrak m^n \to 0
$$
for both local rings we conclude (from the snake lemma)
that $f$ induces isomorphisms
$\mathcal{O}_{Y, y}/\mathfrak m_y^n \to \mathcal{O}_{U, u}/\mathfrak m_u^n$
for all $n$ which is what we wanted to show.
\end{proof}

\begin{lemma}
\label{lemma-relative-map-approximation-pre}
Let $X \to S$, $Y \to T$, $x$, $s$, $y$, $t$, $\sigma$, $y_\sigma$, and
$\varphi$ be given as follows: we have morphisms of schemes
$$
\vcenter{
\xymatrix{
X \ar[d] & Y \ar[d] \\
S & T
}
}
\quad\text{with points}\quad
\vcenter{
\xymatrix{
x \ar[d] & y \ar[d] \\
s & t
}
}
$$
Here $S$ is locally Noetherian and $T$ is of finite type over $\mathbf{Z}$.
The morphisms $X \to S$ and $Y \to T$ are locally of finite type.
The local ring $\mathcal{O}_{S, s}$ is a G-ring. The map
$$
\sigma : \mathcal{O}_{T, t} \longrightarrow \mathcal{O}_{S, s}^\wedge
$$
is a local homomorphism. Set
$Y_\sigma = Y \times_{T, \sigma} \Spec(\mathcal{O}_{S, s}^\wedge)$.
Next, $y_\sigma$ is a point of $Y_\sigma$ mapping to $y$ and
the closed point of $\Spec(\mathcal{O}_{S, s}^\wedge)$. Finally
$$
\varphi :
\mathcal{O}_{X, x}^\wedge
\longrightarrow
\mathcal{O}_{Y_\sigma, y_\sigma}^\wedge
$$
is an isomorphism of $\mathcal{O}_{S, s}^\wedge$-algebras.
In this situation there exists a commutative diagram
$$
\xymatrix{
X \ar[d] &
W \ar[l] \ar[rd] \ar[rr] & &
Y \times_{T, \tau} V \ar[r] \ar[ld] & Y \ar[d] \\
S & &
V \ar[ll] \ar[rr]^\tau & &
T
}
$$
of schemes and points $w \in W$, $v \in V$ such that
\begin{enumerate}
\item $(V, v) \to (S, s)$ is an elementary \'etale neighbourhood,
\item $(W, w) \to (X, x)$ is an elementary \'etale neighbourhood, and
\item $\tau(v) = t$.
\end{enumerate}
Let $y_\tau \in Y \times_T V$ correspond to $y_\sigma$
via the identification $(Y_\sigma)_s = (Y \times_T V)_v$.
Then
\begin{enumerate}
\item[(4)] $(W, w) \to (Y \times_{T, \tau} V, y_\tau)$ is an elementary
\'etale neighbourhood.
\end{enumerate}
\end{lemma}

\begin{proof}
Denote $X_\sigma = X \times_S \Spec(\mathcal{O}_{S, s}^\wedge)$
and $x_\sigma \in X_\sigma$ the unique point lying over $x$.
Observe that $\mathcal{O}_{S, s}^\wedge$ is a G-ring by
More on Algebra, Proposition
\ref{more-algebra-proposition-Noetherian-complete-G-ring}.
By Lemma \ref{lemma-isomorphism-approximation}
we can choose
$$
(X_\sigma, x_\sigma) \leftarrow (U, u) \rightarrow (Y_\sigma, y_\sigma)
$$
where both arrows are elementary \'etale neighbourhoods.

\medskip\noindent
After replacing $S$ by an open neighbourhood of $s$, we may
assume $S = \Spec(R)$ is affine. Since $\mathcal{O}_{S, s}$
is a G-ring by Smoothing Ring Maps, Theorem \ref{smoothing-theorem-popescu}
the ring $\mathcal{O}_{S, s}^\wedge$ is a filtered colimit of smooth
$R$-algebras. Thus we can write
$$
\Spec(\mathcal{O}_{S, s}^\wedge) = \lim S_i
$$
as a directed limit of affine schemes $S_i$ smooth over $S$.
Denote $s_i \in S_i$ the image of the closed point of
$\Spec(\mathcal{O}_{S, s}^\wedge)$. Observe that $\kappa(s) = \kappa(s_i)$.
Set $X_i = X \times_S S_i$ and denote $x_i \in X_i$ the unique
point mapping to $x$. Note that $\kappa(x) = \kappa(x_i)$.
Since $T$ is of finite type over $\mathbf{Z}$ by Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}
we can choose an $i$ and a morphism $\sigma_i : (S_i, s_i) \to (T, t)$
of pointed schemes whose composition with
$\Spec(\mathcal{O}_{S, s}^\wedge) \to S_i$ is equal to $\sigma$.
Set $Y_i = Y \times_T S_i$ and denote $y_i$ the
image of $y_\sigma$. Note that $\kappa(y_i) = \kappa(y_\sigma)$.
By Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
we can choose an $i$ and a diagram
$$
\xymatrix{
X_i \ar[rd] &
U_i \ar[l] \ar[d] \ar[r] &
Y_i \ar[ld] \\
& S_i
}
$$
whose base change to $\Spec(\mathcal{O}_{S, s}^\wedge)$
recovers $X_\sigma \leftarrow U \rightarrow Y_\sigma$.
By Limits, Lemma \ref{limits-lemma-descend-etale}
after increasing $i$ we may assume the morphisms
$X_i \leftarrow U_i \rightarrow Y_i$ are \'etale.
Let $u_i \in U_i$ be the image of $u$. Then $u_i \mapsto x_i$
hence
$\kappa(x) = \kappa(x_\sigma) = \kappa(u) \supset \kappa(u_i) \supset
\kappa(x_i) = \kappa(x)$ and we see that $\kappa(u_i) = \kappa(x_i)$.
Hence $(X_i, x_i) \leftarrow (U_i, u_i)$ is an elementary
\'etale neighbourhood. Since also $\kappa(y_i) = \kappa(y_\sigma) = \kappa(u)$
we see that also $(U_i, u_i) \to (Y_i, y_i)$ is an elementary
\'etale neighbourhood.

\medskip\noindent
At this point we have constructed a diagram
$$
\xymatrix{
X \ar[d] &
X \times_S S_i \ar[l] \ar[rd] &
U_i \ar[l] \ar[r] \ar[d] &
Y \times_T S_i \ar[r] \ar[ld] &
Y \ar[d] \\
S & &
S_i \ar[ll] \ar[rr] & &
T
}
$$
as in the statement of the lemma, except that $S_i \to S$ is smooth.
By Lemma \ref{lemma-slice-smooth} and after shrinking $S_i$
we can assume there exists a closed subscheme $V \subset S_i$ passing
through $s_i$ such that $V \to S$ is \'etale.
Setting $W$ equal to the scheme theoretic inverse image of $V$
in $U_i$ we conclude.
\end{proof}

\noindent
We strongly encourage the reader to skip the rest of this section.

\begin{lemma}
\label{lemma-relative-map-approximation}
Consider a diagram
$$
\vcenter{
\xymatrix{
X \ar[d] & Y \ar[d] \\
S & T \ar[l]
}
}
\quad\text{with points}\quad
\vcenter{
\xymatrix{
x \ar[d] & y \ar[d] \\
s & t \ar[l]
}
}
$$
where $S$ be a locally Noetherian scheme and the morphisms are
locally of finite type. Assume $\mathcal{O}_{S, s}$ is a G-ring.
Assume further we are given a local $\mathcal{O}_{S, s}$-algebra map
$$
\sigma : \mathcal{O}_{T, t} \longrightarrow \mathcal{O}_{S, s}^\wedge
$$
and a local $\mathcal{O}_{S, s}$-algebra map
$$
\varphi :
\mathcal{O}_{X, x}
\longrightarrow
\mathcal{O}_{Y_\sigma, y_\sigma}^\wedge
$$
where $Y_\sigma = Y \times_{T, \sigma} \Spec(\mathcal{O}_{S, s}^\wedge)$
and $y_\sigma$ is the unique point of $Y_\sigma$ lying over $y$.
For every $N \geq 1$ there exists a commutative diagram
$$
\xymatrix{
X \ar[d] & X \times_S V \ar[l] \ar[rd] &
W \ar[l]^-f \ar[r] \ar[d] &
Y \times_{T, \tau} V \ar[r] \ar[ld] & Y \ar[d] \\
S & & V \ar[ll] \ar[rr]^\tau & & T
}
$$
of schemes over $S$ and points $w \in W$, $v \in V$ such that
\begin{enumerate}
\item $v \mapsto s$, $\tau(v) = t$, $f(w) = (x, v)$, and $w \mapsto (y, v)$,
\item $(V, v) \to (S, s)$ is an elementary \'etale neighbourhood,
\item the diagram
$$
\xymatrix{
\mathcal{O}_{S, s}^\wedge \ar[r] & \mathcal{O}_{V, v}^\wedge \\
\mathcal{O}_{T, t} \ar[r]^{\tau^\sharp_v} \ar[u]_\sigma &
\mathcal{O}_{V, v} \ar[u]
}
$$
commutes module $\mathfrak m_v^N$,
\item $(W, w) \to (Y \times_{T, \tau} V, (y, v))$ is an
elementary \'etale neighbourhood,
\item the diagram
$$
\xymatrix{
\mathcal{O}_{X, x} \ar[r]_\varphi &
\mathcal{O}_{Y_\sigma, y_\sigma}^\wedge \ar[r] &
\mathcal{O}_{Y_\sigma, y_\sigma}/\mathfrak m_{y_\sigma}^N \ar@{=}[r] &
\mathcal{O}_{Y \times_{T, \tau} V, (y, v)}/\mathfrak m_{(y, v)}^N
\ar[d]_{\cong} \\
\mathcal{O}_{X, x} \ar[r] \ar@{=}[u] &
\mathcal{O}_{X \times_S V, (x, v)} \ar[r]^{f^\sharp_w} &
\mathcal{O}_{W, w} \ar[r] &
\mathcal{O}_{W, w}/\mathfrak m_w^N
}
$$
commutes. The equality comes from the fact that
$Y_\sigma$ and $Y \times_{T, \tau} V$ are canonically isomorphic over
$\mathcal{O}_{V, v}/\mathfrak m_v^N = \mathcal{O}_{S, s}/\mathfrak m_s^N$
by parts (2) and (3).
\end{enumerate}
\end{lemma}

\begin{proof}
After replacing $X$, $S$, $T$, $Y$ by affine open subschemes we
may assume the diagram in the statement of the lemma comes
from applying $\Spec$ to a diagram
$$
\vcenter{
\xymatrix{
A & B \\
R \ar[u] \ar[r] & C \ar[u]
}
}
\quad\text{with primes}\quad
\vcenter{
\xymatrix{
\mathfrak p_A & \mathfrak p_B \\
\mathfrak p_R \ar@{-}[u] \ar@{-}[r] & \mathfrak p_C \ar@{-}[u]
}
}
$$
of Noetherian rings and finite type ring maps.
In this proof every ring $E$ will be a Noetherian $R$-algebra endowed with
a prime ideal $\mathfrak p_E$ lying over $\mathfrak p_R$ and all ring maps
will be $R$-algebra maps compatible with the given primes. Moreover,
if we write $E^\wedge$ we mean the completion of the localization
of $E$ at $\mathfrak p_E$. We will also use without further mention
that an \'etale ring map $E_1 \to E_2$ such that
$\kappa(\mathfrak p_{E_1}) = \kappa(\mathfrak p_{E_2})$ induces
an isomorphism $E_1^\wedge = E_2^\wedge$ by
More on Algebra, Lemma \ref{more-algebra-lemma-flat-unramified}.

\medskip\noindent
With this notation $\sigma$ and $\varphi$ correspond to ring maps
$$
\sigma : C \to R^\wedge
\quad\text{and}\quad
\varphi : A \longrightarrow (B \otimes_{C, \sigma} R^\wedge)^\wedge
$$
Here is a picture
$$
\xymatrix{
A \ar@/^1em/[rrr]^\varphi &
B \ar[r] &
B \otimes_{C, \sigma} R^\wedge \ar[r] &
(B \otimes_{C, \sigma} R^\wedge)^\wedge \\
R \ar[r] \ar[u] &
C \ar[r]^\sigma \ar[u] & R^\wedge \ar[u] \ar[ru]
}
$$
Observe that $R^\wedge$ is a G-ring by
More on Algebra, Proposition
\ref{more-algebra-proposition-Noetherian-complete-G-ring}.
Thus $B \otimes_{C, \sigma} R^\wedge$ is a G-ring by
More on Algebra, Proposition
\ref{more-algebra-proposition-finite-type-over-G-ring}.
By Lemma \ref{lemma-map-approximation} (translated into algebra)
there exists an \'etale ring map $B \otimes_{C, \sigma} R^\wedge \to B'$
inducing an isomorphism
$\kappa(\mathfrak p_{B \otimes_{C, \sigma} R^\wedge})
\to \kappa(\mathfrak p_{B'})$
and an $R$-algebra map $A \to B'$ such that the composition
$$
A \to B' \to (B')^\wedge = (B \otimes_{C, \sigma} R^\wedge)^\wedge
$$
is the same as $\varphi$ modulo
$(\mathfrak p_{(B \otimes_{C, \sigma} R^\wedge)^\wedge})^N$.
Thus we may replace $\varphi$ by this composition because the
only way $\varphi$ enters the conclusion is via the commutativity
requirement in part (5) of the statement of the lemma.
Picture:
$$
\xymatrix{
& & B' \ar[r] & (B')^\wedge \ar@{=}[d] \\
A \ar[rru] &
B \ar[r] &
B \otimes_{C, \sigma} R^\wedge \ar[r] \ar[u] &
(B \otimes_{C, \sigma} R^\wedge)^\wedge \\
R \ar[r] \ar[u] &
C \ar[r]^\sigma \ar[u] & R^\wedge \ar[u] \ar[ru]
}
$$
Next, we use that $R^\wedge$ is a filtered colimit of smooth
$R$-algebras (Smoothing Ring Maps, Theorem \ref{smoothing-theorem-popescu})
because $R_{\mathfrak p_R}$ is a G-ring by assumption. Since $C$ is of
finite presentation over $R$ we get a factorization
$$
C \to R' \to R^\wedge
$$
for some $R \to R'$ smooth, see
Algebra, Lemma \ref{algebra-lemma-characterize-finite-presentation}.
After increasing $R'$ we may assume there exists
an \'etale $B \otimes_C R'$-algebra $B''$ whose base change
to $B \otimes_{C, \sigma} R^\wedge$ is $B'$, see
Algebra, Lemma \ref{algebra-lemma-etale}.
Then $B'$ is the filtered colimit of these $B''$ and we
conclude that after increasing $R'$ we may assume there is
an $R$-algebra map $A \to B''$ such that $A \to B'' \to B'$ is
the previously constructed map (same reference as above). Picture
$$
\xymatrix{
& & B'' \ar[r] & B' \ar[r] & (B')^\wedge \ar@{=}[d] \\
A \ar[rru] &
B \ar[r] &
B \otimes_C R' \ar[r] \ar[u] &
B \otimes_{C, \sigma} R^\wedge \ar[r] \ar[u] &
(B \otimes_{C, \sigma} R^\wedge)^\wedge \\
R \ar[r] \ar[u] &
C \ar[r] \ar[u] &
R' \ar[r] \ar[u] &
R^\wedge \ar[u] \ar[ru]
}
$$
and
$$
B' = B'' \otimes_{(B \otimes_C R')} (B \otimes_{C, \sigma} R^\wedge)
$$
This means that we may replace $C$ by $R'$, $\sigma : C \to R^\wedge$ by
$R' \to R^\wedge$, and $B$ by $B''$ so that we simplify to the diagram
$$
\xymatrix{
A \ar[r] &
B \ar[r] &
B \otimes_{C, \sigma} R^\wedge \\
R \ar[r] \ar[u] &
C \ar[r]^\sigma \ar[u] & R^\wedge \ar[u]
}
$$
with $\varphi$ equal to the composition of the horizontal arrows
followed by the canonical map from $B \otimes_{C, \sigma} R^\wedge$
to its completion.
The final step in the proof is to apply Lemma \ref{lemma-map-approximation}
(or its proof)
one more time to $\Spec(C)$ and $\Spec(R)$ over $\Spec(R)$ and the map
$C \to R^\wedge$. The lemma produces a ring map $C \to D$
such that $R \to D$ is \'etale, such that
$\kappa(\mathfrak p_R) = \kappa(\mathfrak p_D)$, and such that
$$
C \to D \to D^\wedge = R^\wedge
$$
is equal to $\sigma : C \to R^\wedge$ modulo $(\mathfrak p_{R^\wedge})^N$.
Then we can take
$$
V = \Spec(D)
\quad\text{and}\quad
W = \Spec(B \otimes_C D)
$$
as our solution to the problem posed by the lemma. Namely the diagram
$$
\xymatrix{
A \ar[r] &
B \otimes_{C, \sigma} R^\wedge \ar[r] &
B \otimes_{C, \sigma} R^\wedge/(\mathfrak p_{R^\wedge})^N \ar@{=}[r] &
B \otimes_C D/(\mathfrak p_D)^N \\
A \ar@{=}[u] \ar[r] &
A \otimes_R D \ar[r] &
B \otimes_R D \ar[r] &
B \otimes_C D/(\mathfrak p_D)^N \ar@{=}[u]
}
$$
commutes because $C \to D \to D^\wedge = R^\wedge$ is equal to
$\sigma$ modulo $(\mathfrak p_{R^\wedge})^N$. This proves part (5)
and the other properties are immediate from the construction.
\end{proof}

\begin{lemma}
\label{lemma-control-agreement}
Let $T \to S$ be finite type morphisms of Noetherian schemes.
Let $t \in T$ map to $s \in S$ and let
$\sigma : \mathcal{O}_{T, t} \to \mathcal{O}_{S, s}^\wedge$
be a local $\mathcal{O}_{S, s}$-algebra map. For every $N \geq 1$
there exists a finite type morphism $(T', t') \to (T, t)$
such that $\sigma$ factors through
$\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$
and such that for every local $\mathcal{O}_{S, s}$-algebra map
$\sigma' : \mathcal{O}_{T, t} \to \mathcal{O}_{S, s}^\wedge$
which factors through $\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$
the maps $\sigma$ and $\sigma'$ agree modulo $\mathfrak m_s^N$.
\end{lemma}

\begin{proof}
We may assume $S$ and $T$ are affine. Say $S = \Spec(R)$ and
$T = \Spec(C)$. Let $c_1, \ldots, c_n \in C$ be generators
of $C$ as an $R$-algebra. Let $\mathfrak p \subset R$ be the
prime ideal corresponding to $s$. Say $\mathfrak p = (f_1, \ldots, f_m)$.
After replacing $R$ by a principal localization
(to clear denominators in $R_\mathfrak p$)
we may assume there exist
$r_1, \ldots, r_n \in R$ and $a_{i, I} \in \mathcal{O}_{S, s}^\wedge$
where $I = (i_1, \ldots, i_m)$ with $\sum i_j = N$ such that
$$
\sigma(c_i) = r_i + \sum\nolimits_I a_{i, I} f_1^{i_1} \ldots f_m^{i_m}
$$
in $\mathcal{O}_{S, s}^\wedge$. Then we consider
$$
C' = C[t_{i, I}]/
\left(c_i - r_i - \sum\nolimits_I t_{i, I} f_1^{i_1} \ldots f_m^{i_m}\right)
$$
with $\mathfrak p' = \mathfrak pC' + (t_{i, I})$ and factorization
of $\sigma : C \to \mathcal{O}_{S, s}^\wedge$ through $C'$
given by sending $t_{i, I}$ to $a_{i, I}$.
Taking $T' = \Spec(C')$ works because any $\sigma'$ as in the statement
of the lemma will send $c_i$ to $r_i$ modulo the maximal ideal
to the power $N$.
\end{proof}

\begin{lemma}
\label{lemma-control-graded}
Let $Y \to T \to S$ be finite type morphisms of Noetherian schemes.
Let $t \in T$ map to $s \in S$ and let
$\sigma : \mathcal{O}_{T, t} \to \mathcal{O}_{S, s}^\wedge$
be a local $\mathcal{O}_{S, s}$-algebra map.
There exists a finite type morphism $(T', t') \to (T, t)$
such that $\sigma$ factors through
$\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$
and such that for every local $\mathcal{O}_{S, s}$-algebra map
$\sigma' : \mathcal{O}_{T, t} \to \mathcal{O}_{S, s}^\wedge$
which factors through $\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$
the closed immersions
$$
Y \times_{T, \sigma} \Spec(\mathcal{O}_{S, s}^\wedge) = Y_\sigma
\longleftarrow Y_t \longrightarrow
Y_{\sigma'} =
Y \times_{T, \sigma'} \Spec(\mathcal{O}_{S, s}^\wedge)
$$
have isomorphic conormal algebras.
\end{lemma}

\begin{proof}
A useful observation is that $\kappa(s) = \kappa(t)$ by the existence of
$\sigma$. Observe that the statement makes sense as the fibres of $Y_\sigma$
and $Y_{\sigma'}$ over $s \in \Spec(\mathcal{O}_{S, s}^\wedge)$
are both canonically isomorphic to $Y_t$. We will think of the property
``$\sigma'$ factors through $\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$''
as a constraint on $\sigma'$. If we have several such constraints,
say given by $(T'_i, t'_i) \to (T, t)$, $i = 1, \ldots, n$
then we can combined them by considering
$(T'_1 \times_T \ldots \times_T T'_n, (t'_1, \ldots, t'_n)) \to
(T, t)$. We will use this without further mention in the following.

\medskip\noindent
By Lemma \ref{lemma-control-agreement} we can assume that any $\sigma'$
as in the statement of the lemma is the same as $\sigma$ modulo
$\mathfrak m_s^2$. Note that the conormal algebra of $Y_t$ in
$Y_\sigma$ is just the quasi-coherent graded $\mathcal{O}_{Y_t}$-algebra
$$
\bigoplus\nolimits_{n \geq 0}
\mathfrak m_s^n\mathcal{O}_{Y_\sigma}/
\mathfrak m_s^{n + 1}\mathcal{O}_{Y_\sigma}
$$
and similarly for $Y_{\sigma'}$. Since $\sigma$ and $\sigma'$
agree modulo $\mathfrak m_s^2$ we see that these two algebras
are the same in degrees $0$ and $1$. On the other hand, these
conormal algebras are generated in degree $1$ over degree $0$.
Hence if there is an isomorphism extending the isomorphism
just constructed in degrees $0$ and $1$, then it is unique.

\medskip\noindent
We may assume $S$ and $T$ are affine. Let $Y = Y_1 \cup \ldots \cup Y_n$
be an affine open covering. If we can construct $(T_i', t'_i) \to (T, t)$
as in the lemma such that the desired isomorphism (see previous paragraph)
exists for $Y_i \to T \to S$ and $\sigma$, then these glue by
uniqueness to prove the result for $Y \to T$. Thus we may assume $Y$ is affine.

\medskip\noindent
Write $S = \Spec(R)$, $T = \Spec(C)$, and $Y = \Spec(B)$.
Choose a presentation $B = C[x_1, \ldots, x_n]/(f_1, \ldots, f_m)$.
Denote $R^\wedge = \mathcal{O}_{S, s}^\wedge$.
Let $a_{kj} \in R^\wedge[x_1, \ldots, x_n]$ be polynomials
such that
$$
\sum\nolimits_{j = 1, \ldots, m} a_{kj}\sigma(f_j) = 0,\quad
\text{for }k = 1, \ldots, K
$$
is a set of generators for the module of relations among
the $\sigma(f_j) \in R^\wedge[x_1, \ldots, x_n]$.
Thus we have an exact sequence
\begin{equation}
\label{equation-resolution}
R^\wedge[x_1, \ldots, x_n]^{\oplus K} \to
R^\wedge[x_1, \ldots, x_n]^{\oplus m} \to
R^\wedge[x_1, \ldots, x_n] \to B \otimes_{C, \sigma} R^\wedge \to 0
\end{equation}
Let $c$ be an integer which works in the Artin-Rees lemma for
both the first and the second map in this sequence and the ideal
$\mathfrak m_{R^\wedge}R^\wedge[x_1, \ldots, x_n]$ as defined in
More on Algebra, Section \ref{more-algebra-section-artin-rees}.
Write
$$
a_{kj} = \sum\nolimits_{I \in \Omega} a_{kj, I} x^I
\quad\text{and}\quad
f_j = \sum\nolimits_{I \in \Omega} f_{j, I} x^I
$$
in multiindex notation where $a_{kj, I} \in R^\wedge$, $f_{j, I} \in C$,
and $\Omega$ a finite set of multiindices. Then we see that
$$
\sum\nolimits_{j = 1, \ldots, m,\ I, I' \in \Omega,\ I + I' = I''}
a_{kj, I} \sigma(f_{j, I'}) = 0,\quad
I''\text{ a multiindex}
$$
in $R^\wedge$. Thus we take
$$
C' = C[t_{jk, I}]/
\left(
\sum\nolimits_{j = 1, \ldots, m,\ I, I' \in \Omega,\ I + I' = I''}
t_{kj, I} f_{j, I'},\ I''\text{ a multiindex}\right)
$$
Then $\sigma$ factors through a map $\tilde\sigma : C' \to R^\wedge$
sending $t_{kj, I}$ to $a_{jk, I}$.
Thus $T' = \Spec(C')$ comes with a point $t' \in T'$ such that
$\sigma$ factors through $\mathcal{O}_{T, t} \to \mathcal{O}_{T', t'}$.
Let $t_{kj} = \sum t_{kj, I} x^I$ in $C'[x_1, \ldots, x_n]$.
Then we see that we have a complex
\begin{equation}
\label{equation-resolution-new}
C'[x_1, \ldots, x_n]^{\oplus K} \to
C'[x_1, \ldots, x_n]^{\oplus m} \to
C'[x_1, \ldots, x_n] \to B \otimes_C C' \to 0
\end{equation}
which is exact at $C'[x_1, \ldots, x_n]$ and whose base change
by $\tilde\sigma$ gives (\ref{equation-resolution}).

\medskip\noindent
By Lemma \ref{lemma-control-agreement}
we can find a further morphism $(T'', t'') \to (T', t')$
such that $\tilde\sigma$
factors through $\mathcal{O}_{T', t'} \to \mathcal{O}_{T'', t''}$
and such that if $\sigma' : C \to R^\wedge$
factors through $\mathcal{O}_{T'', t''}$, then the induced map
$\tilde \sigma' : C' \to R^\wedge$
agrees modulo $\mathfrak m_s^{c + 1}$ with $\tilde \sigma$.
Thus if $\sigma'$ is such a map, then we obtain a complex
$$
R^\wedge[x_1, \ldots, x_n]^{\oplus K} \to
R^\wedge[x_1, \ldots, x_n]^{\oplus m} \to
R^\wedge[x_1, \ldots, x_n] \to B \otimes_{C, \sigma'} R^\wedge \to 0
$$
over $R^\wedge[x_1, \ldots, x_n]$ by applying $\tilde\sigma'$
to the polynomials $t_{kj}$ and $f_j$. In other words, this
is the base change of the complex (\ref{equation-resolution-new})
by $\tilde\sigma'$. The matrices defining this complex
are congruent modulo $\mathfrak m_s^{c + 1}$ to the matrices
defining the complex (\ref{equation-resolution}) because
$\tilde \sigma$ and $\tilde \sigma'$ are congruent modulo
$\mathfrak m_s^{c + 1}$. Since (\ref{equation-resolution}) is exact,
we can apply
More on Algebra, Lemma \ref{more-algebra-lemma-approximate-complex-graded}
to conclude that
$$
\text{Gr}_{\mathfrak m_s}(B \otimes_{C, \sigma'} R^\wedge)
\cong
\text{Gr}_{\mathfrak m_s}(B \otimes_{C, \sigma} R^\wedge)
$$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-relative-isomorphism-approximation}
With notation an assumptions as in Lemma \ref{lemma-relative-map-approximation}
assume that $\varphi$ induces an isomorphism on completions.
Then we can choose our diagram such that $f$ is \'etale.
\end{lemma}

\begin{proof}
We may assume $N \geq 2$ and we may replace $(T, t)$ with $(T', t')$ as in
Lemma \ref{lemma-control-graded}. Since $(V, v) \to (S, s)$ is an elementary
\'etale neighbourhood, so is $(X \times_S V, (x, v)) \to (X, x)$.
Thus $\mathcal{O}_{X, x} \to \mathcal{O}_{X \times_S V, (x, v)}$
induces an isomorphism on completions by
More on Algebra, Lemma \ref{more-algebra-lemma-flat-unramified}.
We claim $\mathcal{O}_{X, x} \to \mathcal{O}_{W, w}$ induces
an isomorphism on completions. Having proved this,
Lemma \ref{lemma-lifting-along-artinian-at-point}
will show that $f$ is smooth at $w$ and of course
$f$ is unramified at $u$ as well, so
Morphisms, Lemma \ref{morphisms-lemma-etale-smooth-unramified}
tells us $f$ is \'etale at $w$.

\medskip\noindent
First we use the commutativity in part (5) of
Lemma \ref{lemma-relative-map-approximation}
to see that for $i \leq N$ there is a commutative diagram
$$
\xymatrix{
\text{Gr}^i_{\mathfrak m_x}(\mathcal{O}_{X, x})
\ar[r]_-\varphi &
\text{Gr}^i_{\mathfrak m_{y_\sigma}}(\mathcal{O}_{Y_\sigma, y_\sigma}^\wedge)
\ar@{=}[r] &
\text{Gr}^i_{\mathfrak m_{(y, v)}}(\mathcal{O}_{Y \times_{T, \tau} V, (y, v)})
\ar[d]_{\cong} \\
\text{Gr}^i_{\mathfrak m_x}(\mathcal{O}_{X, x})
\ar[r]^-{\cong} \ar@{=}[u] &
\text{Gr}^i_{\mathfrak m_{(x, v)}}(\mathcal{O}_{X \times_S V, (x, v)})
\ar[r]^{f^\sharp_w} &
\text{Gr}^i_{\mathfrak m_w}(\mathcal{O}_{W, w})
}
$$
This implies that $f^\sharp_w$ defines an isomorphism
$\kappa(x) \to \kappa(w)$ on residue fields and an isomorphism
$\mathfrak m_x/\mathfrak m_x^2 \to \mathfrak m_w/\mathfrak m_w^2$
on cotangent spaces. Hence $f^\sharp_w$ defines a surjection
$\mathcal{O}_{X, x}^\wedge \to \mathcal{O}_{W, w}^\wedge$
on complete local rings.

\medskip\noindent
By Lemma \ref{lemma-control-graded} there is an isomorphism of
$\text{Gr}_{\mathfrak m_s}(\mathcal{O}_{(Y \times_{T, \tau} V, (y, v)})$
with
$\text{Gr}_{\mathfrak m_s}(\mathcal{O}_{Y_\sigma, y_\sigma})$.
This follows by taking stalks of the isomorphism of conormal
sheaves at the point $y$. Since our local rings are Noetherian
taking associated graded with respect to $\mathfrak m_s$
commutes with completion because completion with respect to an ideal
is an exact functor on finite modules over Noetherian rings.
This produces the right vertical isomorphism in the diagram of graded rings
$$
\xymatrix{
\text{Gr}_{\mathfrak m_s}(\mathcal{O}_{W, w}^\wedge) &
\text{Gr}_{\mathfrak m_s}
(\mathcal{O}_{(Y \times_{T, \tau} V, (y, v)}^\wedge) \ar[l] \\
\text{Gr}_{\mathfrak m_s}(\mathcal{O}_{X, x}^\wedge)
\ar[r]^\varphi \ar[u] &
\text{Gr}_{\mathfrak m_s}(\mathcal{O}_{Y_\sigma, y_\sigma}^\wedge)
\ar[u]_{\cong}
}
$$
We do not claim the diagram commutes. By the result of the previous
paragraph the left arrow is surjective. The other three arrows
are isomorphisms. It follows that the left arrow is a surjective map
between isomorphic Noetherian rings. Hence it is an isomorphism
by Algebra, Lemma \ref{algebra-lemma-surjective-endo-noetherian-ring-is-iso}
(you can argue this directly using Hilbert functions as well).
In particular $\mathcal{O}_{X, x}^\wedge \to \mathcal{O}_{W, w}^\wedge$
must be injective as well as surjective which finishes the proof.
\end{proof}















\section{Finite free locally dominates \'etale}
\label{section-finite-free-over-etale}

\noindent
In this section we explain a result that roughly states that
\'etale coverings of a scheme $S$ can be refined by Zariski coverings
of finite locally free covers of $S$.

\begin{lemma}
\label{lemma-dominate-etale-neighbourhood-finite-flat}
Let $S$ be a scheme. Let $s \in S$.
Let $f : (U, u) \to (S, s)$ be an \'etale neighbourhood.
There exists an affine open neighbourhood $s \in V \subset S$
and a surjective, finite locally free morphism $\pi : T \to V$
such that for every $t \in \pi^{-1}(s)$ there exists an
open neighbourhood $t \in W_t \subset T$ and a commutative
diagram
$$
\xymatrix{
T \ar[d]^\pi & W_t \ar[l] \ar[rr]_{h_t} \ar[rd] & & U \ar[dl] \\
V \ar[rr] & & S
}
$$
with $h_t(t) = u$.
\end{lemma}

\begin{proof}
The problem is local on $S$ hence we may replace $S$ by any
open neighbourhood of $s$.
We may also replace $U$ by an open neighbourhood of $u$.
Hence, by Morphisms, Lemma \ref{morphisms-lemma-etale-locally-standard-etale}
we may assume that
$U \to S$ is a standard \'etale morphism of affine schemes.
In this case the lemma (with $V = S$) follows from
Algebra, Lemma \ref{algebra-lemma-standard-etale-finite-flat-Zariski}.
\end{proof}

\begin{lemma}
\label{lemma-dominate-etale-affine-finite-flat}
Let $f : U \to S$ be a surjective \'etale morphism of affine schemes.
There exists a surjective, finite locally free morphism
$\pi : T \to S$ and a finite open covering
$T = T_1 \cup \ldots \cup T_n$ such that each
$T_i \to S$ factors through $U \to S$. Diagram:
$$
\xymatrix{
& \coprod T_i  \ar[rd] \ar[ld] & \\
T \ar[rd]^\pi & & U \ar[ld]_f \\
& S &
}
$$
where the south-west arrow is a Zariski-covering.
\end{lemma}

\begin{proof}
This is a restatement of
Algebra, Lemma \ref{algebra-lemma-etale-finite-flat-zariski}.
\end{proof}

\begin{remark}
\label{remark-topologies}
In terms of topologies
Lemmas \ref{lemma-dominate-etale-neighbourhood-finite-flat} and
\ref{lemma-dominate-etale-affine-finite-flat} mean the following.
Let $S$ be any scheme. Let $\{f_i : U_i \to S\}$ be an \'etale covering
of $S$. There exists a Zariski open covering $S = \bigcup V_j$,
for each $j$ a finite locally free, surjective morphism
$W_j \to V_j$, and for each $j$ a Zariski open covering
$\{W_{j, k} \to W_j\}$ such that the family
$\{W_{j, k} \to S\}$ refines the given \'etale covering
$\{f_i : U_i \to S\}$. What does this mean in practice?
Well, for example, suppose we have a descent problem which we
know how to solve for Zariski coverings and for fppf coverings
of the form $\{\pi : T \to S\}$ with $\pi$ finite locally free
and surjective. Then this descent problem has an affirmative
answer for \'etale coverings as well. This trick was used by
Gabber in his proof that $\text{Br}(X) = \text{Br}'(X)$
for an affine scheme $X$, see \cite{Hoobler}.
\end{remark}




\section{\'Etale localization of quasi-finite morphisms}
\label{section-etale-localization}

\noindent
Now we come to a series of lemmas around the theme
``quasi-finite morphisms become finite after \'etale localization''.
The general idea is the following. Suppose given a morphism
of schemes $f : X \to S$ and a point $s \in S$. Let
$\varphi : (U, u) \to (S, s)$ be an \'etale neighbourhood of $s$ in $S$.
Consider the fibre product $X_U = U \times_S X$ and the
basic diagram
\begin{equation}
\label{equation-basic-diagram}
\vcenter{
\xymatrix{
V \ar[r] \ar[dr] & X_U \ar[d] \ar[r] & X \ar[d]^f \\
& U \ar[r]^\varphi & S
}
}
\end{equation}
where $V \subset X_U$ is open.
Is there some standard model for the morphism $f_U : X_U \to U$, or for
the morphism $V \to U$ for suitable opens $V$?
Of course the answer is no in general. But for quasi-finite morphisms
we can say something.

\begin{lemma}
\label{lemma-etale-makes-quasi-finite-finite-at-point}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$. Set $s = f(x)$.
Assume that
\begin{enumerate}
\item $f$ is locally of finite type, and
\item $x \in X_s$ is isolated\footnote{In the presence of (1)
this means that $f$ is
quasi-finite at $x$, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize}.}.
\end{enumerate}
Then there exist
\begin{enumerate}
\item[(a)] an elementary \'etale neighbourhood $(U, u) \to (S, s)$,
\item[(b)] an open subscheme $V \subset X_U$
(see \ref{equation-basic-diagram})
\end{enumerate}
such that
\begin{enumerate}
\item[(\romannumeral1)] $V \to U$ is a finite morphism,
\item[(\romannumeral2)] there is a unique point $v$ of $V$
mapping to $u$ in $U$, and
\item[(\romannumeral3)] the point $v$ maps to $x$
under the morphism $X_U \to X$, inducing $\kappa(x) = \kappa(v)$.
\end{enumerate}
Moreover, for any elementary \'etale neighbourhood $(U', u') \to (U, u)$
setting $V' = U' \times_U V \subset X_{U'}$ the triple $(U', u', V')$
satisfies the properties
(\romannumeral1), (\romannumeral2), and (\romannumeral3) as well.
\end{lemma}

\begin{proof}
Let $Y \subset X$, $W \subset S$ be affine opens such that
$f(Y) \subset W$ and such that $x \in Y$. Note that $x$ is
also an isolated point of the fibre of the morphism $f|_Y : Y \to W$.
If we can prove the theorem for $f|_Y : Y \to W$, then the
theorem follows for $f$. Hence we reduce to the case where
$f$ is a morphism of affine schemes. This case is
Algebra, Lemma \ref{algebra-lemma-etale-makes-quasi-finite-finite-one-prime}.
\end{proof}

\noindent
In the preceding and following lemma we do not assume that the morphism
$f$ is separated. This means that the opens $V$, $V_i$ created
in them are not necessarily closed in $X_U$. Moreover, if we choose
the neighbourhood $U$ to be affine, then each $V_i$ is affine, but
the intersections $V_i \cap V_j$ need not be affine (in the nonseparated
case).

\begin{lemma}
\label{lemma-etale-makes-quasi-finite-finite-multiple-points}
Let $f : X \to S$ be a morphism of schemes.
Let $x_1, \ldots, x_n \in X$ be points having the same image $s$ in $S$.
Assume that
\begin{enumerate}
\item $f$ is locally of finite type, and
\item $x_i \in X_s$ is isolated for $i = 1, \ldots, n$.
\end{enumerate}
Then there exist
\begin{enumerate}
\item[(a)] an elementary \'etale neighbourhood $(U, u) \to (S, s)$,
\item[(b)] for each $i$ an open subscheme $V_i \subset X_U$,
\end{enumerate}
such that for each $i$ we have
\begin{enumerate}
\item[(\romannumeral1)] $V_i \to U$ is a finite morphism,
\item[(\romannumeral2)] there is a unique point $v_i$ of $V_i$
mapping to $u$ in $U$, and
\item[(\romannumeral3)] the point $v_i$ maps to $x_i$ in $X$ and
$\kappa(x_i) = \kappa(v_i)$.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use induction on $n$.
Namely, suppose $(U, u) \to (S, s)$ and $V_i \subset X_U$,
$i = 1, \ldots, n - 1$ work for $x_1, \ldots, x_{n - 1}$. Since
$\kappa(s) = \kappa(u)$ the fibre $(X_U)_u = X_s$. Hence there
exists a unique point $x'_n \in X_u \subset X_U$ corresponding to
$x_n \in X_s$. Also $x'_n$ is isolated in $X_u$. Hence by
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point} there
exists an elementary \'etale neighbourhood $(U', u') \to (U, u)$
and an open $V_n \subset X_{U'}$ which works for $x'_n$ and hence
for $x_n$.
By the final assertion of
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}
the open subschemes $V'_i = U'\times_U V_i$ for $i = 1, \ldots, n - 1$ still
work with respect to $x_1, \ldots, x_{n - 1}$. Hence we win.
\end{proof}

\noindent
If we allow a nontrivial field extension $\kappa(u)/\kappa(s)$, i.e.,
general \'etale neighbourhoods, then we can split the points as follows.

\begin{lemma}
\label{lemma-etale-makes-quasi-finite-finite-multiple-points-var}
Let $f : X \to S$ be a morphism of schemes.
Let $x_1, \ldots, x_n \in X$ be points having the same image $s$ in $S$.
Assume that
\begin{enumerate}
\item $f$ is locally of finite type, and
\item $x_i \in X_s$ is isolated for $i = 1, \ldots, n$.
\end{enumerate}
Then there exist
\begin{enumerate}
\item[(a)] an \'etale neighbourhood $(U, u) \to (S, s)$,
\item[(b)] for each $i$ an integer $m_i$ and
open subschemes $V_{i, j} \subset X_U$, $j = 1, \ldots, m_i$
\end{enumerate}
such that we have
\begin{enumerate}
\item[(\romannumeral1)] each $V_{i, j} \to U$ is a finite morphism,
\item[(\romannumeral2)] there is a unique point $v_{i, j}$ of $V_{i, j}$
mapping to $u$ in $U$ with $\kappa(u) \subset \kappa(v_{i, j})$
finite purely inseparable,
\item[(\romannumeral4)] if $v_{i, j} = v_{i', j'}$, then $i = i'$ and
$j = j'$, and
\item[(\romannumeral3)] the points $v_{i, j}$ map to $x_i$ in $X$ and
no other points of $(X_U)_u$ map to $x_i$.
\end{enumerate}
\end{lemma}

\begin{proof}
This proof is a variant of the proof of
Algebra, Lemma \ref{algebra-lemma-etale-makes-quasi-finite-finite-variant}
in the language of schemes.
By Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize}
the morphism $f$ is quasi-finite at each of the points $x_i$.
Hence $\kappa(s) \subset \kappa(x_i)$ is finite for each $i$
(Morphisms, Lemma \ref{morphisms-lemma-residue-field-quasi-finite}).
For each $i$, let $\kappa(s) \subset L_i \subset \kappa(x_i)$
be the subfield such that $L_i/\kappa(s)$ is separable, and
$\kappa(x_i)/L_i$ is purely inseparable. Choose a finite Galois
extension $L/\kappa(s)$ such that there exist
$\kappa(s)$-embeddings $L_i \to L$ for $i = 1, \ldots, n$.
Choose an \'etale neighbourhood $(U, u) \to (S, s)$ such that
$L \cong \kappa(u)$ as $\kappa(s)$-extensions
(Lemma \ref{lemma-realize-prescribed-residue-field-extension-etale}).

\medskip\noindent
Let $y_{i, j}$, $j = 1, \ldots, m_i$ be the points of $X_U$
lying over $x_i \in X$ and $u \in U$. By
Schemes, Lemma \ref{schemes-lemma-points-fibre-product}
these points $y_{i, j}$ correspond exactly to the primes in the rings
$\kappa(u) \otimes_{\kappa(s)} \kappa(x_i)$. This also
explains why there are finitely many; in fact
$m_i = [L_i : \kappa(s)]$ but we do not need this.
By our choice of
$L$ (and elementary field theory)
we see that $\kappa(u) \subset \kappa(y_{i, j})$ is
finite purely inseparable for each pair $i, j$.
Also, by Morphisms, Lemma \ref{morphisms-lemma-base-change-quasi-finite}
for example, the morphism
$X_U \to U$ is quasi-finite at the points $y_{i, j}$ for
all $i, j$.

\medskip\noindent
Apply Lemma \ref{lemma-etale-makes-quasi-finite-finite-multiple-points}
to the morphism $X_U \to U$, the point $u \in U$
and the points $y_{i, j} \in (X_U)_u$. This gives an \'etale neighbourhood
$(U', u') \to (U, u)$ with $\kappa(u) = \kappa(u')$ and
opens $V_{i, j} \subset X_{U'}$ with the properties
(\romannumeral1), (\romannumeral2), and (\romannumeral3)
of that lemma. We claim that the \'etale neighbourhood
$(U', u') \to (S, s)$ and the opens $V_{i, j} \subset X_{U'}$
are a solution to the problem posed by the lemma.
We omit the verifications.
\end{proof}

\begin{lemma}
\label{lemma-etale-splits-off-quasi-finite-part-technical}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$. Let $x_1, \ldots, x_n \in X_s$. Assume that
\begin{enumerate}
\item $f$ is locally of finite type,
\item $f$ is separated, and
\item $x_1, \ldots, x_n$ are pairwise distinct isolated points of $X_s$.
\end{enumerate}
Then there exists an elementary \'etale neighbourhood $(U, u) \to (S, s)$
and a decomposition
$$
U \times_S X = W \amalg V_1 \amalg \ldots \amalg V_n
$$
into open and closed subschemes such that the morphisms
$V_i \to U$ are finite, the fibres of $V_i \to U$ over $u$ are
singletons $\{v_i\}$, each $v_i$ maps to $x_i$ with
$\kappa(x_i) = \kappa(v_i)$, and the fibre of $W \to U$
over $u$ contains no points mapping to any of the $x_i$.
\end{lemma}

\begin{proof}
Choose $(U, u) \to (S, s)$ and $V_i \subset X_U$ as in
Lemma \ref{lemma-etale-makes-quasi-finite-finite-multiple-points}.
Since $X_U \to U$ is separated
(Schemes, Lemma \ref{schemes-lemma-separated-permanence})
and $V_i \to U$ is finite hence proper
(Morphisms, Lemma \ref{morphisms-lemma-finite-proper})
we see that $V_i \subset X_U$ is closed by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}.
Hence $V_i \cap V_j$ is a closed subset of $V_i$ which
does not contain $v_i$. Hence the image of $V_i \cap V_j$
in $U$ is a closed set (because $V_i \to U$ proper) not
containing $u$. After shrinking $U$ we may therefore assume
that $V_i \cap V_j = \emptyset$ for all $i, j$. This gives the
decomposition as in the lemma.
\end{proof}

\noindent
Here is the variant where we reduce to purely inseparable
field extensions.

\begin{lemma}
\label{lemma-etale-splits-off-quasi-finite-part-technical-variant}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$. Let $x_1, \ldots, x_n \in X_s$. Assume that
\begin{enumerate}
\item $f$ is locally of finite type,
\item $f$ is separated, and
\item $x_1, \ldots, x_n$ are pairwise distinct isolated points of $X_s$.
\end{enumerate}
Then there exists an \'etale neighbourhood $(U, u) \to (S, s)$
and a decomposition
$$
U \times_S X =
W \amalg
\ \coprod\nolimits_{i = 1, \ldots, n}
\ \coprod\nolimits_{j = 1, \ldots, m_i}
V_{i, j}
$$
into open and closed subschemes such that the morphisms
$V_{i, j} \to U$ are finite, the fibres of $V_{i, j} \to U$ over $u$ are
singletons $\{v_{i, j}\}$, each $v_{i, j}$ maps to $x_i$,
$\kappa(u) \subset \kappa(v_{i, j})$ is purely inseparable,
and the fibre of $W \to U$ over $u$ contains no points mapping
to any of the $x_i$.
\end{lemma}

\begin{proof}
This is proved in exactly the same way as the proof of
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical} except that it
uses Lemma \ref{lemma-etale-makes-quasi-finite-finite-multiple-points-var}
instead of Lemma \ref{lemma-etale-makes-quasi-finite-finite-multiple-points}.
\end{proof}

\noindent
The following version may be a little easier to parse.

\begin{lemma}
\label{lemma-etale-splits-off-quasi-finite-part}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$. Assume that
\begin{enumerate}
\item $f$ is locally of finite type,
\item $f$ is separated, and
\item $X_s$ has at most finitely many isolated points.
\end{enumerate}
Then there exists an elementary \'etale neighbourhood $(U, u) \to (S, s)$
and a decomposition
$$
U \times_S X = W \amalg V
$$
into open and closed subschemes such that the morphism
$V \to U$ is finite, and the fibre $W_u$ of the
morphism $W \to U$ contains no isolated points.
In particular, if $f^{-1}(s)$ is a finite set, then $W_u = \emptyset$.
\end{lemma}

\begin{proof}
This is clear from
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical}
by choosing $x_1, \ldots, x_n$ the complete set of
isolated points of $X_s$ and setting $V = \bigcup V_i$.
\end{proof}






\section{\'Etale localization of integral morphisms}
\label{section-etale-localization-integral}

\noindent
Some variants of the results of Section \ref{section-etale-localization}
for the case of integral morphisms.

\begin{lemma}
\label{lemma-etale-makes-integral-split}
Let $R \to S$ be an integral ring map. Let $\mathfrak p \subset R$ be a prime
ideal. Assume
\begin{enumerate}
\item there are finitely many primes $\mathfrak q_1, \ldots, \mathfrak q_n$
lying over $\mathfrak p$, and
\item for each $i$ the maximal separable subextension
$\kappa(\mathfrak q)/\kappa(\mathfrak q_i)_{sep}/\kappa(\mathfrak p)$
(Fields, Lemma \ref{fields-lemma-separable-first})
is finite over $\kappa(\mathfrak p)$.
\end{enumerate}
Then there exists an \'etale ring map $R \to R'$ and a prime
$\mathfrak p'$ lying over $\mathfrak p$ such that
$$
S \otimes_R R' = A_1 \times \ldots \times A_m
$$
with $R' \to A_j$ integral having a unique prime $\mathfrak r_j$
over $\mathfrak p'$ such that $\kappa(\mathfrak r_j)/\kappa(\mathfrak p')$
is purely inseparable.
\end{lemma}

\begin{proof}[First proof]
This proof uses
Algebra, Lemma \ref{algebra-lemma-etale-makes-quasi-finite-finite-variant}.
Namely, choose a generator $\theta_i \in \kappa(\mathfrak q_i)_{sep}$
of this field over $\kappa(\mathfrak p)$
(Fields, Lemma \ref{fields-lemma-primitive-element}).
The spectrum of the fibre ring $S \otimes_R \kappa(\mathfrak p)$
is finite discrete with points corresponding to
$\mathfrak q_1, \ldots, \mathfrak q_n$.
By the Chinese remainder theorem
(Algebra, Lemma \ref{algebra-lemma-chinese-remainder})
we see that $S \otimes_R \kappa(\mathfrak p) \to \prod \kappa(\mathfrak q_i)$
is surjective. Hence after replacing $R$ by $R_g$ for some
$g \in R$, $g \not \in \mathfrak p$ we may assume that
$(0, \ldots, 0, \theta_i, 0, \ldots, 0) \in \prod \kappa(\mathfrak q_i)$
is the image of some $x_i \in S$.
Let $S' \subset S$ be the $R$-subalgebra generated by our $x_i$.
Since $\Spec(S) \to \Spec(S')$ is surjective
(Algebra, Lemma \ref{algebra-lemma-integral-overring-surjective})
we conclude that
$\mathfrak q_i' = S' \cap \mathfrak q_i$ are the primes of
$S'$ over $\mathfrak p$. By our choice of $x_i$ we conclude
these primes are distinct that and
$\kappa(\mathfrak q'_i)_{sep} = \kappa(\mathfrak q_i)_{sep}$.
In particular the field extensions
$\kappa(\mathfrak q_i)/\kappa(\mathfrak q'_i)$ are purely
inseparable.
Since $R \to S'$ is finite we may apply
Algebra, Lemma \ref{algebra-lemma-etale-makes-quasi-finite-finite-variant}.
and we get $R \to R'$ and $\mathfrak p'$ and a decomposition
$$
S' \otimes_R R' = A'_1 \times \ldots \times A'_m \times B'
$$
with $R' \to A'_j$ integral having a unique prime
$\mathfrak r'_j$ over $\mathfrak p'$ such that
$\kappa(\mathfrak r'_j)/\kappa(\mathfrak p')$
is purely inseparable and such that $B'$ does not have a prime
lying over $\mathfrak p'$. Since $R' \to B'$ is finite
(as $R \to S'$ is finite) we can
after localizing $R'$ at some $g' \in R'$, $g' \not \in \mathfrak p'$
assume that $B' = 0$. Via the map $S' \otimes_R R' \to S \otimes_R R'$
we get the corresponding decomposition for $S$.
\end{proof}

\begin{proof}[Second proof]
This proof uses strict henselization. First, assume $R$ is strictly
henselization with maximal ideal $\mathfrak p$. Then $S/\mathfrak p S$
has finitely many primes corresponding to
$\mathfrak q_1, \ldots, \mathfrak q_n$, each maximal,
each with purely inseparable residue field over $\kappa(\mathfrak p)$.
Hence $S/\mathfrak p S$ is equal to $\prod (S/\mathfrak p S)_{\mathfrak p_i}$.
By More on Algebra, Lemma \ref{more-algebra-lemma-characterize-henselian-pair}
we can lift this product decomposition to a product composition of $S$
as in the statement.

\medskip\noindent
In the general case, let $R^{sh}$ be the strict henselization of
$R_\mathfrak p$. Then we can apply the result of the first paragraph
to $R^{sh} \to S \otimes_R R^{sh}$. Consider the $m$ mutually orthogonal
idempotents in $S \otimes_R R^{sh}$ corresponding to the product
decomposition. Since $R^{sh}$ is a filtered colimit of \'etale
ring maps $(R, \mathfrak p) \to (R', \mathfrak p')$ by
Algebra, Lemma \ref{algebra-lemma-strict-henselization-different}
we see that these idempotents descend to some $R'$ as desired.
\end{proof}







\section{Zariski's Main Theorem}
\label{section-application-etale-neighbourhoods}

\noindent
In this section we prove Zariski's main theorem as reformulated by Grothendieck.
Often when we say ``Zariski's main theorem'' in this content we mean either of
Lemma \ref{lemma-finite-type-separated},
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}, or
Lemma \ref{lemma-quasi-finite-separated-pass-through-finite}.
In most texts people refer to the last of these as
Zariski's main theorem.

\medskip\noindent
We have already proved the algebraic version in
Algebra, Theorem \ref{algebra-theorem-main-theorem}
and we have already restated this algebraic version
in the language of schemes, see
Morphisms, Theorem \ref{morphisms-theorem-main-theorem}.
The version in this section is more subtle; to get the full
result we use the \'etale localization techniques
of Section \ref{section-etale-localization} to reduce to
the algebraic case.

\begin{lemma}
\label{lemma-finite-type-separated}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is of finite type and separated.
Let $S'$ be the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
Picture:
$$
\xymatrix{
X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\
& S &
}
$$
Then there exists an open subscheme $U' \subset S'$ such that
\begin{enumerate}
\item $(f')^{-1}(U') \to U'$ is an isomorphism, and
\item $(f')^{-1}(U') \subset X$ is the set of points at which
$f$ is quasi-finite.
\end{enumerate}
\end{lemma}

\begin{proof}
By Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open}
the subset $U \subset X$ of points where $f$ is quasi-finite is open.
The lemma is equivalent to
\begin{enumerate}
\item[(a)] $U' = f'(U) \subset S'$ is open,
\item[(b)] $U = (f')^{-1}(U')$, and
\item[(c)] $U \to U'$ is an isomorphism.
\end{enumerate}
Let $x \in U$ be arbitrary. We claim there exists an open
neighbourhood $f'(x) \in V \subset S'$ such that $(f')^{-1}V \to V$ is an
isomorphism. We first prove the claim implies the lemma.
Namely, then $(f')^{-1}V \cong V$ is both locally of finite
type over $S$ (as an open subscheme of $X$) and for $v \in V$ the residue
field extension $\kappa(v)/\kappa(\nu(v))$ is algebraic (as
$V \subset S'$ and $S'$ is integral over $S$). Hence the fibres
of $V \to S$ are discrete (Morphisms, Lemma
\ref{morphisms-lemma-algebraic-residue-field-extension-closed-point-fibre})
and $(f')^{-1}V \to S$ is locally quasi-finite
(Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-fibres}).
This implies $(f')^{-1}V \subset U$ and $V \subset U'$. Since $x$ was
arbitrary we see that (a), (b), and (c) are true.

\medskip\noindent
Let $s = f(x)$. Let $(T, t) \to (S, s)$ be an elementary \'etale
neighbourhood. Denote by a subscript ${}_T$ the base change to $T$.
Let $y = (x, t) \in X_T$ be the unique point in
the fibre $X_t$ lying over $x$. Note that $U_T \subset X_T$
is the set of points where $f_T$ is quasi-finite, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-quasi-finite}.
Note that
$$
X_T \xrightarrow{f'_T} S'_T \xrightarrow{\nu_T} T
$$
is the normalization of $T$ in $X_T$, see
Lemma \ref{lemma-normalization-smooth-localization}.
Suppose that the claim holds for $y \in U_T \subset X_T \to S'_T \to T$, i.e.,
suppose that we can find an open neighbourhood
$f'_T(y) \in V' \subset S'_T$ such that $(f'_T)^{-1}V' \to V'$ is an
isomorphism. The morphism $S'_T \to S'$ is \'etale hence the image
$V \subset S'$ of $V'$ is open. Observe that $f'(x) \in V$ as $f'_T(y) \in V'$.
Observe that
$$
\xymatrix{
(f'_T)^{-1}V' \ar[r] \ar[d] & (f')^{-1}(V) \ar[d] \\
V' \ar[r] & V
}
$$
is a fibre square (as $S'_T \times_{S'} X = X_T$).
Since the left vertical arrow is an isomorphism
and $\{V' \to V\}$ is a \'etale covering, we conclude that the right vertical
arrow is an isomorphism by
Descent, Lemma \ref{descent-lemma-descending-property-isomorphism}.
In other words, the claim holds for $x \in U \subset X \to S' \to S$.

\medskip\noindent
By the result of the previous paragraph we may replace $S$ by an
elementary \'etale neighbourhood of $s = f(x)$ in order to prove the claim.
Thus we may assume there is a decomposition
$$
X = V \amalg W
$$
into open and closed subschemes where $V \to S$ is finite and $x \in V$,
see Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical}.
Since $X$ is a disjoint union of $V$ and $W$ over $S$ and since
$V \to S$ is finite we see that the
normalization of $S$ in $X$ is the morphism
$$
X = V \amalg W \longrightarrow V \amalg W' \longrightarrow S
$$
where $W'$ is the normalization of $S$ in $W$, see
Morphisms, Lemmas \ref{morphisms-lemma-normalization-in-disjoint-union},
\ref{morphisms-lemma-finite-integral}, and
\ref{morphisms-lemma-normalization-in-integral}.
The claim follows and we win.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-separated-quasi-affine}
\begin{slogan}
Quasi-finite, separated morphisms are quasi-affine
\end{slogan}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is quasi-finite and separated.
Let $S'$ be the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
Picture:
$$
\xymatrix{
X \ar[rd]_f \ar[rr]_{f'} & & S' \ar[ld]^\nu \\
& S &
}
$$
Then $f'$ is a quasi-compact open immersion and $\nu$ is integral.
In particular $f$ is quasi-affine.
\end{lemma}

\begin{proof}
This follows from Lemma \ref{lemma-finite-type-separated}. Namely, by
that lemma there exists an open subscheme $U' \subset S'$ such that
$(f')^{-1}(U') = X$ and $X \to U'$ is an isomorphism. In other
words, $f'$ is an open immersion. Note that $f'$ is quasi-compact as
$f$ is quasi-compact and $\nu : S' \to S$ is separated
(Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}).
It follows that $f$ is quasi-affine by
Morphisms, Lemma \ref{morphisms-lemma-characterize-quasi-affine}.
\end{proof}

\begin{lemma}[Zariski's Main Theorem]
\label{lemma-quasi-finite-separated-pass-through-finite}
\begin{reference}
\cite[IV Corollary 18.12.13]{EGA}
\end{reference}
Let $f : X \to S$ be a morphism of schemes.
Assume $f$ is quasi-finite and separated and assume that
$S$ is quasi-compact and quasi-separated. Then there exists
a factorization
$$
\xymatrix{
X \ar[rd]_f \ar[rr]_j & & T \ar[ld]^\pi \\
& S &
}
$$
where $j$ is a quasi-compact open immersion and $\pi$ is finite.
\end{lemma}

\begin{proof}
Let $X \to S' \to S$ be as in the conclusion of
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
By
Properties, Lemma
\ref{properties-lemma-integral-algebra-directed-colimit-finite}
we can write
$\nu_*\mathcal{O}_{S'} = \colim_{i \in I} \mathcal{A}_i$ as a
directed colimit of finite quasi-coherent $\mathcal{O}_X$-algebras
$\mathcal{A}_i \subset \nu_*\mathcal{O}_{S'}$. Then
$\pi_i : T_i = \underline{\Spec}_S(\mathcal{A}_i) \to S$
is a finite morphism for each $i$.
Note that the transition morphisms $T_{i'} \to T_i$ are affine
and that $S' = \lim T_i$.

\medskip\noindent
By Limits, Lemma \ref{limits-lemma-descend-opens}
there exists an $i$ and a quasi-compact open
$U_i \subset T_i$ whose inverse image in $S'$ equals
$f'(X)$. For $i' \geq i$ let $U_{i'}$ be the inverse image
of $U_i$ in $T_{i'}$. Then $X \cong f'(X) = \lim_{i' \geq i} U_{i'}$, see
Limits, Lemma \ref{limits-lemma-directed-inverse-system-has-limit}.
By Limits, Lemma \ref{limits-lemma-finite-type-eventually-closed} we see that
$X \to U_{i'}$ is a closed immersion for some $i' \geq i$.
(In fact $X \cong U_{i'}$ for sufficiently
large $i'$ but we don't need this.) Hence $X \to T_{i'}$ is an immersion. By
Morphisms, Lemma \ref{morphisms-lemma-factor-quasi-compact-immersion}
we can factor this as $X \to T \to T_{i'}$ where the first arrow
is an open immersion and the second a closed immersion. Thus we win.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-separated-pass-through-finite-addendum}
With notation and hypotheses as in
Lemma \ref{lemma-quasi-finite-separated-pass-through-finite}.
Assume moreover that $f$ is locally of finite presentation. Then we can
choose the factorization such that $T$ is finite and of
finite presentation over $S$.
\end{lemma}

\begin{proof}
By Limits, Lemma
\ref{limits-lemma-finite-in-finite-and-finite-presentation} we can write
$T = \lim T_i$ where all $T_i$ are finite and of finite presentation
over $Y$ and the transition morphisms $T_{i'} \to T_i$ are closed
immersions. By
Limits, Lemma \ref{limits-lemma-descend-opens}
there exists an $i$ and an open subscheme $U_i \subset T_i$ whose inverse
image in $T$ is $X$. By
Limits, Lemma
\ref{limits-lemma-finite-type-eventually-closed}
we see that $X \cong U_i$ for large enough $i$.
Replacing $T$ by $T_i$ finishes the proof.
\end{proof}








\section{Applications of Zariski's Main Theorem, I}
\label{section-applications-zmt}

\noindent
A first application is the characterization of finite
morphisms as proper morphisms with finite fibres.

\begin{lemma}
\label{lemma-characterize-finite}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent:
\begin{enumerate}
\item $f$ is finite,
\item $f$ is proper with finite fibres,
\item $f$ is proper and locally quasi-finite,
\item $f$ is universally closed, separated, locally of finite type
and has finite fibres.
\end{enumerate}
\end{lemma}

\begin{proof}
We have (1) implies (2) by
Morphisms, Lemmas \ref{morphisms-lemma-finite-proper},
\ref{morphisms-lemma-quasi-finite},
and \ref{morphisms-lemma-finite-quasi-finite}.
We have (2) implies (3) by Morphisms, Lemma \ref{morphisms-lemma-finite-fibre}.
We have (3) implies (4) by the definition of proper morphisms and
Morphisms, Lemmas \ref{morphisms-lemma-quasi-finite-locally-quasi-compact} and
\ref{morphisms-lemma-quasi-finite}.

\medskip\noindent
Assume (4). Pick $s \in S$. By
Morphisms, Lemma \ref{morphisms-lemma-finite-fibre} we
see that all the finitely many points of $X_s$ are isolated in $X_s$.
Choose an elementary \'etale neighbourhood $(U, u) \to (S, s)$
and decomposition $X_U = V \amalg W$ as in
Lemma \ref{lemma-etale-splits-off-quasi-finite-part}.
Note that $W_u = \emptyset$ because all points of $X_s$ are isolated.
Since $f$ is universally closed we see that
the image of $W$ in $U$ is a closed set not containing $u$.
After shrinking $U$ we may assume that $W = \emptyset$.
In other words we see that $X_U = V$ is finite over $U$.
Since $s \in S$ was arbitrary
this means there exists a family $\{U_i \to S\}$
of \'etale morphisms whose images cover $S$ such that
the base changes $X_{U_i} \to U_i$ are finite.
Note that $\{U_i \to S\}$ is an \'etale covering,
see Topologies, Definition \ref{topologies-definition-etale-covering}.
Hence it is an fpqc covering, see
Topologies,
Lemma \ref{topologies-lemma-zariski-etale-smooth-syntomic-fppf-fpqc}.
Hence we conclude $f$ is finite by
Descent, Lemma \ref{descent-lemma-descending-property-finite}.
\end{proof}

\noindent
As a consequence we have the following useful results.

\begin{lemma}
\label{lemma-proper-finite-fibre-finite-in-neighbourhood}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$.
Assume that $f$ is proper and $f^{-1}(\{s\})$ is a finite set.
Then there exists an open neighbourhood $V \subset S$ of $s$
such that $f|_{f^{-1}(V)} : f^{-1}(V) \to V$ is finite.
\end{lemma}

\begin{proof}
The morphism $f$ is quasi-finite at all the points of $f^{-1}(\{s\})$
by Morphisms, Lemma \ref{morphisms-lemma-finite-fibre}.
By Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-points-open} the
set of points at which $f$ is quasi-finite is an open $U \subset X$.
Let $Z = X \setminus U$. Then $s \not \in f(Z)$. Since $f$ is proper
the set $f(Z) \subset S$ is closed. Choose any open neighbourhood
$V \subset S$ of $s$ with $f(Z) \cap V = \emptyset$. Then
$f^{-1}(V) \to V$ is locally quasi-finite and proper.
Hence it is quasi-finite
(Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-locally-quasi-compact}),
hence has finite fibres
(Morphisms, Lemma \ref{morphisms-lemma-quasi-finite}), hence
is finite by Lemma \ref{lemma-characterize-finite}.
\end{proof}

\begin{lemma}
\label{lemma-flat-proper-family-cannot-collapse-fibre}
Consider a commutative diagram of schemes
$$
\xymatrix{
X \ar[rr]_h \ar[rd]_f & & Y \ar[ld]^g \\
& S
}
$$
Let $s \in S$. Assume
\begin{enumerate}
\item $X \to S$ is a proper morphism,
\item $Y \to S$ is separated and locally of finite type, and
\item the image of $X_s \to Y_s$ is finite.
\end{enumerate}
Then there is an open
subspace $U \subset S$ containing $s$ such that $X_U \to Y_U$
factors through a closed subscheme $Z \subset Y_U$ finite over $U$.
\end{lemma}

\begin{proof}
Let $Z \subset Y$ be the scheme theoretic image of $h$, see
Morphisms, Section \ref{morphisms-section-scheme-theoretic-image}.
By Morphisms, Lemma \ref{morphisms-lemma-scheme-theoretic-image-is-proper}
the morphism $X \to Z$ is surjective and $Z \to S$ is proper.
Thus $X_s \to Z_s$ is surjective. We see that either
(3) implies $Z_s$ is finite.
Hence $Z \to S$ is finite in an open neighbourhood of $s$ by
Lemma \ref{lemma-proper-finite-fibre-finite-in-neighbourhood}.
\end{proof}





\section{Applications of Zariski's Main Theorem, II}
\label{section-applications-zmt-II}

\noindent
In this section we give a few more consequences of Zariski's main theorem
to the structure of quasi-finite morphisms.

\begin{lemma}
\label{lemma-separated-locally-quasi-finite-over-affine}
Let $f : X \to Y$ be a separated, locally quasi-finite morphism
with $Y$ affine. Then every finite set of points of $X$ is contained
in an open affine of $X$.
\end{lemma}

\begin{proof}
Let $x_1, \ldots, x_n \in X$. Choose a quasi-compact open
$U \subset X$ with $x_i \in U$. Then $U \to Y$ is quasi-affine by
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
Hence there exists an affine open $V \subset U$ containing
$x_1, \ldots, x_n$ by
Properties, Lemma \ref{properties-lemma-ample-finite-set-in-affine}.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-finite-over-dense-open}
Let $f : Y \to X$ be a quasi-finite morphism.
There exists a dense open $U \subset X$ such that
$f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
\end{lemma}

\begin{proof}
If $U_i \subset X$, $i \in I$ is a collection of opens such that the
restrictions $f|_{f^{-1}(U_i)} : f^{-1}(U_i) \to U_i$ are finite,
then with $U = \bigcup U_i$ the restriction $f|_{f^{-1}(U)} : f^{-1}(U) \to U$
is finite, see
Morphisms, Lemma \ref{morphisms-lemma-finite-local}.
Thus the problem is local on $X$ and we may assume that $X$ is affine.

\medskip\noindent
Assume $X$ is affine.
Write $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine.
This is possible since $f$ is quasi-finite and hence
in particular quasi-compact. Each $V_j \to X$ is quasi-finite
and separated. Let $\eta \in X$ be a generic point of an irreducible
component of $X$. We see from
Morphisms, Lemmas
\ref{morphisms-lemma-quasi-finite} and \ref{morphisms-lemma-generically-finite}
that there exists an open neighbourhood $\eta \in U_\eta$ such that
$f^{-1}(U_\eta) \cap V_j \to U_\eta$ is finite. We may choose $U_\eta$ such
that it works for each $j = 1, \ldots, m$.
Note that the collection of generic points of $X$ is dense in $X$.
Thus we see there exists a dense open $W = \bigcup_\eta U_\eta$
such that each $f^{-1}(W) \cap V_j \to W$ is finite.
It suffices to show that there exists a dense open $U \subset W$
such that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
Thus we may replace $X$ by an affine open subscheme of $W$ and
assume that each $V_j \to X$ is finite.

\medskip\noindent
Assume $X$ is affine, $Y = \bigcup_{j = 1, \ldots, m} V_j$ with $V_j$ affine,
and the restrictions $f|_{V_j} : V_j \to X$ are finite.
Set
$$
\Delta_{ij} =
\Big(\overline{V_i \cap V_j} \setminus V_i \cap V_j\Big) \cap V_j.
$$
This is a nowhere dense closed subset of $V_j$ because it is the boundary
of the open subset $V_i \cap V_j$ in $V_j$. By
Morphisms, Lemma \ref{morphisms-lemma-image-nowhere-dense-finite}
the image $f(\Delta_{ij})$ is a nowhere dense closed subset of $X$. By
Topology, Lemma \ref{topology-lemma-nowhere-dense}
the union $T = \bigcup f(\Delta_{ij})$ is a nowhere dense closed
subset of $X$. Thus $U = X \setminus T$ is a dense open subset of $X$.
We claim that $f|_{f^{-1}(U)} : f^{-1}(U) \to U$ is finite.
To see this let $U' \subset U$ be an affine open.
Set $Y' = f^{-1}(U') = U' \times_X Y$,
$V_j' = Y' \cap V_j = U' \times_X V_j$. Consider the restriction
$$
f' = f|_{Y'} : Y' \longrightarrow U'
$$
of $f$. This morphism now has the property that
$Y' = \bigcup_{j = 1, \ldots, m} V'_j$ is an affine open covering,
each $V'_j \to U'$ is finite, and $V_i' \cap V_j'$ is (open and) closed
both in $V'_i$ and $V'_j$. Hence $V_i' \cap V_j'$ is affine, and the map
$$
\mathcal{O}(V'_i) \otimes_{\mathbf{Z}} \mathcal{O}(V'_j)
\longrightarrow
\mathcal{O}(V'_i \cap V'_j)
$$
is surjective. This implies that $Y'$ is separated, see
Schemes, Lemma \ref{schemes-lemma-characterize-separated}.
Finally, consider the commutative diagram
$$
\xymatrix{
\coprod_{j = 1, \ldots, m} V'_j \ar[rd] \ar[rr] & & Y' \ar[ld] \\
& U' &
}
$$
The south-east arrow is finite, hence proper, the horizontal arrow is
surjective, and the south-west arrow is separated. Hence by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-is-proper}
we conclude that $Y' \to U'$ is proper. Since it is also quasi-finite,
we see that it is finite by Lemma \ref{lemma-characterize-finite},
and we win.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-lqf-universally-bounded}
Let $f : X \to S$ be flat, locally of finite presentation, separated,
locally quasi-finite with universally bounded fibres. Then there exist
closed subsets
$$
\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset
\ldots \subset Z_n = S
$$
such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification
$S = \coprod_{r = 0, \ldots, n} S_r$ is characterized by the following
universal property: Given $g : T \to S$ the projection
$X \times_S T \to T$ is finite locally
free of degree $r$ if and only if $g(T) \subset S_r$ (set theoretically).
\end{lemma}

\begin{proof}
Let $n$ be an integer bounding the degree of the fibres of $X \to S$.
By Morphisms, Lemma \ref{morphisms-lemma-base-change-universally-bounded}
we see that any base change has degrees of fibres bounded by $n$ also.
In particular, all the integers $r$ that occur in the statement of the lemma
will be $\leq n$. We will prove the lemma by induction on $n$. The base
case is $n = 0$ which is obvious.

\medskip\noindent
We claim the set of points $s \in S$
with $\deg_{\kappa(s)}(X_s) = n$ is an open subset $S_n \subset S$
and that $X \times_S S_n \to S_n$ is finite locally free of degree $n$.
Namely, suppose that $s \in S$ is such a point. Choose an elementary
\'etale morphism $(U, u) \to (S, s)$ and a decomposition
$U \times_S X = W \amalg V$ as in
Lemma \ref{lemma-etale-splits-off-quasi-finite-part}.
Since $V \to U$ is finite, flat, and locally of finite presentation,
we see that $V \to U$ is finite locally free, see
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}.
After shrinking $U$ to a smaller neighbourhood of $u$
we may assume $V \to U$ is finite locally free of some degree $d$, see
Morphisms, Lemma \ref{morphisms-lemma-finite-locally-free}.
As $u \mapsto s$ and $W_u = \emptyset$ we see that $d = n$. Since $n$
is the maximum degree of a fibre we see that $W = \emptyset$!
Thus $U \times_S X \to U$ is finite locally free of degree $n$.
By Descent, Lemma \ref{descent-lemma-descending-property-finite-locally-free}
we conclude that $X \to S$ is finite locally free of degree $n$
over $\Im(U \to S)$ which is an open neighbourhood of $s$
(Morphisms, Lemma \ref{morphisms-lemma-etale-open}).
This proves the claim.

\medskip\noindent
Let $S' = S \setminus S_n$ endowed with the reduced induced scheme
structure and set $X' = X \times_S S'$. Note that the degrees of fibres
of $X' \to S'$ are universally bounded by $n - 1$. By induction we find a
stratification $S' = S_0 \amalg \ldots \amalg S_{n - 1}$ adapted
to the morphism $X' \to S'$. We claim that $S = \coprod_{r = 0, \ldots, n} S_r$
works for the morphism $X \to S$. Let $g : T \to S$ be a morphism of schemes
and assume that $X \times_S T \to T$ is finite locally free of degree $r$.
As remarked above this implies that $r \leq n$. If $r = n$, then it is
clear that $T \to S$ factors through $S_n$. If $r < n$, then
$g(T) \subset S' = S \setminus S_d$ (set theoretically) hence
$T_{red} \to S$ factors through $S'$, see
Schemes, Lemma \ref{schemes-lemma-map-into-reduction}.
Note that $X \times_S T_{red} \to T_{red}$ is also
finite locally free of degree $r$ as a base change.
By the universal property of the stratification
$S' = \coprod_{r = 0, \ldots, n - 1} S_r$ we see that $g(T) = g(T_{red})$
is contained in $S_r$.
Conversely, suppose that we have $g : T \to S$ such that
$g(T) \subset S_r$ (set theoretically).
If $r = n$, then $g$ factors through $S_n$ and
it is clear that $X \times_S T \to T$
is finite locally free of degree $n$ as a base change.
If $r < n$, then $X \times_S T \to T$ is a morphism which is
separated, flat, and locally of finite presentation, such that
the restriction to $T_{red}$ is finite locally free of degree $r$.
Since $T_{red} \to T$ is a universal homeomorphism, we conclude
that $X \times_S T_{red} \to X \times_S T$ is a universal homeomorphism
too and hence $X \times_S T \to T$ is universally closed (as this
is true for the finite morphism $X \times_S T_{red} \to T_{red}$).
It follows that $X \times_S T \to T$ is finite, for example by
Lemma \ref{lemma-characterize-finite}. Then we can use
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}
to see that $X \times_S T \to T$ is finite locally free.
Finally, the degree is $r$ as all the fibres have degree $r$.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-qf}
Let $f : X \to S$ be a morphism of schemes which is flat, locally of
finite presentation, separated, and quasi-finite. Then there exist
closed subsets
$$
\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset
\ldots \subset S
$$
such that with $S_r = Z_r \setminus Z_{r - 1}$ the stratification
$S = \coprod S_r$ is characterized by the following universal property:
Given a morphism $g : T \to S$ the projection $X \times_S T \to T$ is
finite locally free of degree $r$ if and only if $g(T) \subset S_r$
(set theoretically). Moreover, the inclusion maps $S_r \to S$ are
quasi-compact.
\end{lemma}

\begin{proof}
The question is local on $S$, hence we may assume that $S$ is affine.
By Morphisms, Lemma
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}
the fibres of $f$ are universally bounded in this case.
Hence the existence of the stratification follows from
Lemma \ref{lemma-stratify-flat-fp-lqf-universally-bounded}.

\medskip\noindent
We will show that $U_r = S \setminus Z_r \to S$ is quasi-compact for
each $r \geq 0$. This will prove the final statement by elementary topology.
Since a composition of quasi-compact maps is quasi-compact
it suffices to prove that $U_r \to U_{r - 1}$ is quasi-compact.
Choose an affine open $W \subset U_{r - 1}$. Write $W = \Spec(A)$.
Then $Z_r \cap W = V(I)$ for some ideal $I \subset A$
and $X \times_S \Spec(A/I) \to \Spec(A/I)$ is finite locally
free of degree $r$. Note that $A/I = \colim A/I_i$ where $I_i \subset I$
runs through the finitely generated ideals. By
Limits, Lemma \ref{limits-lemma-descend-finite-locally-free}
we see that $X \times_S \Spec(A/I_i) \to \Spec(A/I_i)$
is finite locally free of degree $r$ for some $i$. (This uses
that $X \to S$ is of finite presentation, as it is locally of finite
presentation, separated, and quasi-compact.)
Hence $\Spec(A/I_i) \to \Spec(A) = W$ factors (set theoretically)
through $Z_r \cap W$. It follows that $Z_r \cap W = V(I_i)$ is the zero
set of a finite subset of elements of $A$. This means that
$W \setminus Z_r$ is a finite union of standard opens, hence quasi-compact,
as desired.
\end{proof}

\begin{lemma}
\label{lemma-stratify-flat-fp-lqf}
Let $f : X \to S$ be a flat, locally of finite presentation, separated, and
locally quasi-finite morphism of schemes. Then there
exist open subschemes
$$
S = U_0 \supset U_1 \supset U_2 \supset \ldots
$$
such that a morphism $\Spec(k) \to S$ factors through $U_d$ if and
only if $X \times_S \Spec(k)$ has degree $\geq d$ over $k$.
\end{lemma}

\begin{proof}
The statement simply means that the collection of points where the degree
of the fibre is $\geq d$ is open. Thus we can work locally on $S$ and
assume $S$ is affine. In this case, for every $W \subset X$ quasi-compact
open, the set of points $U_d(W)$ where the fibres of $W \to S$ have
degree $\geq d$ is open by Lemma \ref{lemma-stratify-flat-fp-qf}.
Since $U_d = \bigcup_W U_d(W)$ the result follows.
\end{proof}

\begin{lemma}
\label{lemma-go-down-with-annihilators}
Let $f : X \to S$ be a morphism of schemes which is flat, locally of
finite presentation, and locally quasi-finite. Let
$g \in \Gamma(X, \mathcal{O}_X)$ nonzero. Then there exist
an open $V \subset X$ such that $g|_V \not = 0$, an open
$U \subset S$ fitting into a commutative diagram
$$
\xymatrix{
V \ar[r] \ar[d]_\pi & X \ar[d]^f \\
U \ar[r] & S,
}
$$
a quasi-coherent subsheaf $\mathcal{F} \subset \mathcal{O}_U$, an integer
$r > 0$, and an injective $\mathcal{O}_U$-module map
$\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$
whose image contains $g|_V$.
\end{lemma}

\begin{proof}
We may assume $X$ and $S$ affine. We obtain a filtration
$\emptyset = Z_{-1} \subset Z_0 \subset Z_1 \subset Z_2 \subset \ldots
\subset Z_n = S$ as in
Lemmas \ref{lemma-stratify-flat-fp-lqf-universally-bounded} and
\ref{lemma-stratify-flat-fp-qf}.
Let $T \subset X$ be the scheme theoretic support of the finite
$\mathcal{O}_X$-module $\Im(g : \mathcal{O}_X \to \mathcal{O}_X)$.
Note that $T$ is the support of $g$ as a section of $\mathcal{O}_X$
(Modules, Definition \ref{modules-definition-support}) and
for any open $V \subset X$ we have $g|_V \not = 0$ if and only if
$V \cap T \not = \emptyset$.
Let $r$ be the smallest integer such that $f(T) \subset Z_r$
set theoretically. Let $\xi \in T$ be a generic point of an irreducible
component of $T$ such that $f(\xi) \not \in Z_{r - 1}$ (and hence
$f(\xi) \in Z_r$). We may replace $S$ by an affine neighbourhood of
$f(\xi)$ contained in $S \setminus Z_{r - 1}$. Write $S = \Spec(A)$
and let $I = (a_1, \ldots, a_m) \subset A$ be a finitely generated ideal
such that $V(I) = Z_r$ (set theoretically, see
Algebra, Lemma \ref{algebra-lemma-qc-open}).
Since the support of $g$ is contained in $f^{-1}V(I)$ by our choice of $r$
we see that there exists an integer $N$ such that
$a_j^N g = 0$ for $j = 1, \ldots, m$. Replacing $a_j$ by $a_j^r$
we may assume that $Ig = 0$. For any $A$-module $M$ write
$M[I]$ for the $I$-torsion of $M$, i.e., $M[I] = \{m \in M \mid Im = 0\}$.
Write $X = \Spec(B)$, so $g \in B[I]$. Since $A \to B$ is flat we
see that
$$
B[I] = A[I] \otimes_A B \cong A[I] \otimes_{A/I} B/IB
$$
By our choice of $Z_r$, the $A/I$-module $B/IB$ is
finite locally free of rank $r$. Hence after replacing $S$ by
a smaller affine open neighbourhood of $f(\xi)$ we may assume
that $B/IB \cong (A/IA)^{\oplus r}$ as $A/I$-modules.
Choose a map $\psi : A^{\oplus r} \to B$ which reduces modulo $I$ to the
isomorphism of the previous sentence. Then we see that
the induced map
$$
A[I]^{\oplus r} \longrightarrow B[I]
$$
is an isomorphism. The lemma follows by taking $\mathcal{F}$ the
quasi-coherent sheaf associated to the $A$-module $A[I]$ and
the map $\mathcal{F}^{\oplus r} \to \pi_*\mathcal{O}_V$ the
one corresponding to $A[I]^{\oplus r} \subset A^{\oplus r} \to B$.
\end{proof}

\begin{lemma}
\label{lemma-there-is-a-scheme-integral-over}
Let $U \to X$ be a surjective \'etale morphism of schemes. Assume $X$
is quasi-compact and quasi-separated. Then there exists a surjective
integral morphism $Y \to X$, such that for
every $y \in Y$ there is an open neighbourhood $V \subset Y$
such that $V \to X$ factors through $U$. In fact, we may assume
$Y \to X$ is finite and of finite presentation.
\end{lemma}

\begin{proof}
Since $X$ is quasi-compact, there exist finitely many affine opens
$U_i \subset U$ such that $U' = \coprod U_i \to X$ is surjective.
After replacing $U$ by $U'$, we see that we may assume $U$ is affine.
In particular $U \to X$ is separated
(Schemes, Lemma \ref{schemes-lemma-affine-separated}).
Then there exists an integer $d$ bounding the degree of the geometric
fibres of $U \to X$ (see Morphisms, Lemma
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}).
We will prove the lemma by induction on $d$ for all quasi-compact
and separated schemes $U$ mapping surjective and \'etale onto $X$.
If $d = 1$, then $U = X$ and the result holds with $Y = U$.
Assume $d > 1$.

\medskip\noindent
We apply Lemma \ref{lemma-quasi-finite-separated-quasi-affine}
and we obtain a factorization
$$
\xymatrix{
U \ar[rr]_j \ar[rd] & & Y \ar[ld]^\pi \\
& X
}
$$
with $\pi$ integral and $j$ a quasi-compact open immersion. We may and do
assume that $j(U)$ is scheme theoretically dense in $Y$. Note that
$$
U \times_X Y = U \amalg W
$$
where the first summand is the image of $U \to U \times_X Y$
(which is closed by
Schemes, Lemma \ref{schemes-lemma-semi-diagonal}
and open because it is \'etale as a morphism between schemes \'etale over $Y$)
and the second summand is the (open and closed) complement.
The image $V \subset Y$ of $W$ is an open subscheme containing
$Y \setminus U$.

\medskip\noindent
The \'etale morphism $W \to Y$ has geometric fibres of cardinality $< d$.
Namely, this is clear for geometric points of $U \subset Y$ by inspection.
Since $U \subset Y$ is dense, it holds for all geometric points of $Y$
for example by Lemma
\ref{lemma-stratify-flat-fp-lqf-universally-bounded}
(the degree of the fibres of a quasi-compact separated \'etale morphism
does not go up under specialization). Thus we may apply the induction
hypothesis to $W \to V$ and find a surjective integral morphism
$Z \to V$ with $Z$ a scheme, which Zariski locally factors through $W$.
Choose a factorization $Z \to Z' \to Y$ with $Z' \to Y$ integral and
$Z \to Z'$ open immersion
(Lemma \ref{lemma-quasi-finite-separated-quasi-affine}).
After replacing $Z'$ by the scheme theoretic closure of $Z$ in $Z'$
we may assume that $Z$ is scheme theoretically dense in $Z'$.
After doing this we have $Z' \times_Y V = Z$. Finally,
let $T \subset Y$ be the induced reduced closed subscheme structure
on $Y \setminus V$. Consider the morphism
$$
Z' \amalg T \longrightarrow X
$$
This is a surjective integral morphism by construction.
Since $T \subset U$ it is clear that the morphism $T \to X$
factors through $U$. On the other hand, let $z \in Z'$
be a point. If $z \not \in Z$, then $z$ maps to a point of
$Y \setminus V \subset U$ and we find a neighbourhood of $z$
on which the morphism factors through $U$.
If $z \in Z$, then we have a neighbourhood $\Omega \subset Z$
which factors through $W \subset U \times_X Y$ and hence through $U$.
This proves existence.

\medskip\noindent
Assume we have found $Y \to X$ integral and surjective which Zariski
locally factors through $U$. Choose a finite affine open covering
$Y = \bigcup V_j$ such that $V_j \to X$ factors through $U$. We can
write $Y = \lim Y_i$ with $Y_i \to X$ finite and of finite
presentation, see Limits, Lemma
\ref{limits-lemma-integral-limit-finite-and-finite-presentation}.
For large enough $i$ we can find affine opens $V_{i, j} \subset Y_i$
whose inverse image in $Y$ recovers $V_j$, see
Limits, Lemma \ref{limits-lemma-descend-opens}.
For even larger $i$ the morphisms $V_j \to U$ over $X$ come
from morphisms $V_{i, j} \to U$ over $X$, see
Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}.
This finishes the proof.
\end{proof}







\section{Application to morphisms with connected fibres}
\label{section-application-geometrically-connected}

\noindent
In this section we prove some lemmas that produce morphisms all of
whose fibres are geometrically connected or geometrically integral.
This will be useful in our study of the local structure of morphisms
of finite type later.

\begin{lemma}
\label{lemma-descent-connected-fibres}
Consider a diagram of morphisms of schemes
$$
\xymatrix{
Z \ar[r]_{\sigma} \ar[rd] & X \ar[d] \\
& Y
}
$$
an a point $y \in Y$. Assume
\begin{enumerate}
\item $X \to Y$ is of finite presentation and flat,
\item $Z \to Y$ is finite locally free,
\item $Z_y \not = \emptyset$,
\item all fibres of $X \to Y$ are geometrically reduced, and
\item $X_y$ is geometrically connected over $\kappa(y)$.
\end{enumerate}
Then there exists a quasi-compact open $X^0 \subset X$ such that $X^0_y = X_y$
and such that all nonempty fibres of $X^0 \to Y$ are geometrically connected.
\end{lemma}

\begin{proof}
In this proof we will use that flat, finite presentation, finite locally
free are properties that are preserved under base change and composition.
We will also use that a finite locally free morphism is both open and
closed. You can find these facts as
Morphisms, Lemmas
\ref{morphisms-lemma-base-change-flat},
\ref{morphisms-lemma-base-change-finite-presentation},
\ref{morphisms-lemma-base-change-finite-locally-free},
\ref{morphisms-lemma-composition-flat},
\ref{morphisms-lemma-composition-finite-presentation},
\ref{morphisms-lemma-composition-finite-locally-free},
\ref{morphisms-lemma-fppf-open}, and
\ref{morphisms-lemma-finite-proper}.

\medskip\noindent
Note that $X_Z \to Z$ is flat morphism of finite presentation
which has a section $s$ coming from $\sigma$. Let $X_Z^0$ denote
the subset of $X_Z$ defined in
Situation \ref{situation-connected-along-section}.
By
Lemma \ref{lemma-connected-along-section-open}
it is an open subset of $X_Z$.

\medskip\noindent
The pullback $X_{Z \times_Y Z}$ of $X$ to $Z \times_Y Z$ comes equipped
with two sections $s_0, s_1$, namely the base changes of $s$ by
$\text{pr}_0, \text{pr}_1 : Z \times_Y Z \to Z$. The construction of
Situation \ref{situation-connected-along-section}
gives two subsets $(X_{Z \times_Y Z})_{s_0}^0$ and
$(X_{Z \times_Y Z})_{s_1}^0$. By
Lemma \ref{lemma-base-change-connected-along-section}
these are the inverse images of $X_Z^0$ under the morphisms
$1_X \times \text{pr}_0, 1_X \times \text{pr}_1 : X_{Z \times_Y Z} \to X_Z$.
In particular these subsets are open.

\medskip\noindent
Let $(Z \times_Y Z)_y = \{z_1, \ldots, z_n\}$.
As $X_y$ is geometrically connected, we see that the fibres of
$(X_{Z \times_Y Z})_{s_0}^0$ and $(X_{Z \times_Y Z})_{s_1}^0$
over each $z_i$ agree (being equal to the whole fibre). Another
way to say this is that
$$
s_0(z_i) \in (X_{Z \times_Y Z})_{s_1}^0
\quad\text{and}\quad
s_1(z_i) \in (X_{Z \times_Y Z})_{s_0}^0.
$$
Since the sets $(X_{Z \times_Y Z})_{s_0}^0$ and $(X_{Z \times_Y Z})_{s_1}^0$
are open in $X_{Z \times_Y Z}$ there exists an open neighbourhood
$W \subset Z \times_Y Z$ of $(Z \times_Y Z)_y$ such that
$$
s_0(W) \subset (X_{Z \times_Y Z})_{s_1}^0
\quad\text{and}\quad
s_1(W) \subset (X_{Z \times_Y Z})_{s_0}^0.
$$
Then it follows directly from the construction in
Situation \ref{situation-connected-along-section}
that
$$
p^{-1}(W) \cap (X_{Z \times_Y Z})_{s_0}^0
=
p^{-1}(W) \cap (X_{Z \times_Y Z})_{s_1}^0
$$
where $p : X_{Z \times_Y Z} \to Z \times_W Z$ is the projection.
Because $Z \times_Y Z \to Y$ is finite locally free, hence open and closed,
there exists an affine open neighbourhood $V \subset Y$ of $y$ such that
$q^{-1}(V) \subset W$, where $q : Z \times_Y Z \to Y$ is the
structure morphism. To prove the lemma we may replace $Y$ by $V$.
After we do this we see that $X_Z^0 \subset Y_Z$ is an open such that
$$
(1_X \times \text{pr}_0)^{-1}(X_Z^0) =
(1_X \times \text{pr}_1)^{-1}(X_Z^0).
$$
This means that the image $X^0 \subset X$ of $X_Z^0$ is an open such
that $(X_Z \to X)^{-1}(X^0) = X_Z^0$, see
Descent, Lemma \ref{descent-lemma-open-fpqc-covering}.
Finally, $X^0$ is quasi-compact because $X_Z^0$ is quasi-compact
by Lemma \ref{lemma-connected-along-section-locally-constructible}
(use that at this point $Y$ is affine, hence $X$ is quasi-compact and
quasi-separated, hence locally constructible is the same as constructible
and in particular quasi-compact; details omitted).
In this way we see that $X^0$ has all the desired properties.
\end{proof}

\begin{lemma}
\label{lemma-fibre-geometrically-connected-reduced}
Let $h : Y \to S$ be a morphism of schemes.
Let $s \in S$ be a point.
Let $T \subset Y_s$ be an open subscheme.
Assume
\begin{enumerate}
\item $h$ is flat and of finite presentation,
\item all fibres of $h$ are geometrically reduced, and
\item $T$ is geometrically connected over $\kappa(s)$.
\end{enumerate}
Then we can find an affine elementary \'etale neighbourhood
$(S', s') \to (S, s)$
and a quasi-compact open $V \subset Y_{S'}$ such that
\begin{enumerate}
\item[(a)] all fibres of $V \to S'$ are geometrically connected,
\item[(b)] $V_{s'} = T \times_s s'$.
\end{enumerate}
\end{lemma}

\begin{proof}
The problem is clearly local on $S$, hence we may replace $S$ by an
affine open neighbourhood of $s$.
The topology on $Y_s$ is induced from the topology on $Y$, see
Schemes, Lemma \ref{schemes-lemma-fibre-topological}.
Hence we can find a quasi-compact open $V \subset Y$ such that $V_s = T$.
The restriction of $h$ to $V$ is quasi-compact (as $S$ affine and $V$
quasi-compact), quasi-separated, locally of finite presentation, and
flat hence flat of finite presentation.
Thus after replacing $Y$ by $V$ we may assume, in addition
to (1) and (2) that $Y_s = T$ and $S$ affine.

\medskip\noindent
Pick a closed point $y \in Y_s$ such that $h$ is Cohen-Macaulay at $y$, see
Lemma \ref{lemma-flat-finite-presentation-CM-open}.
By
Lemma \ref{lemma-slice-CM}
there exists a diagram
$$
\xymatrix{
Z \ar[r] \ar[rd] & Y \ar[d] \\
& S
}
$$
such that $Z \to S$ is flat, locally of finite presentation, locally
quasi-finite with $Z_s = \{y\}$. Apply
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}
to find an elementary neighbourhood $(S', s') \to (S, s)$ and an open
$Z' \subset Z_{S'} = S' \times_S Z$ with $Z' \to S'$ finite with a unique
point $z' \in Z'$ lying over $s$. Note that $Z' \to S'$ is also
locally of finite presentation and flat (as an open of the base change
of $Z \to S$), hence $Z' \to S'$ is finite locally free, see
Morphisms, Lemma \ref{morphisms-lemma-finite-flat}.
Note that $Y_{S'} \to S'$ is flat and of finite presentation
with geometrically reduced fibres as a base change of $h$.
Also $Y_{s'} = Y_s$ is geometrically connected.
Apply Lemma \ref{lemma-descent-connected-fibres}
to $Z' \to Y_{S'}$ over $S'$ to get $V \subset Y_{S'}$ quasi-compact open
satisfying (2) whose fibres over $S'$ are either empty or
geometrically connected. As $V \to S'$ is open
(Morphisms, Lemma \ref{morphisms-lemma-fppf-open}), after replacing
$S'$ by an affine open neighbourhood of $s'$
we may assume $V \to S'$ is surjective, whence (1) holds.
\end{proof}

\begin{lemma}
\label{lemma-cover-by-geometrically-connected}
Let $f : X \to S$ be a morphism of schemes which is
locally of finite presentation and flat with geometrically
reduced fibres. Then there
exists an \'etale covering $\{X_i \to X\}_{i \in I}$
such that $X_i \to S$ factors as $X_i \to S_i \to S$
where $S_i \to S$ is \'etale and $X_i \to S_i$ is
flat of finite presentation with geometrically connected
and geometrically reduced fibres.
\end{lemma}

\begin{proof}
Pick a point $x \in X$ with image $s \in S$. We will produce
a diagram
$$
\xymatrix{
X' \ar[r] \ar[rd] & S' \times_S X \ar[r] \ar[d] & X \ar[d] \\
& S' \ar[r] & S
}
$$
and points $s' \in S'$, $x' \in X'$, $y \in S' \times_S X$
such that $x'$ maps to $x$, $(S', s') \to (S, s)$
is an \'etale neighbourhood, $(X', x') \to (S' \times_S X, y)$
is an \'etale neighbourhood\footnote{The proof actually gives
an open $X' \subset S' \times_S X$.}, and
$X' \to S'$ has geometrically
connected fibres. If we can do this for every $x \in X$, then
the lemma follows (with members of the covering given by the
collection of \'etale morphisms $X' \to X$ so produced).
The first step is the replace $X$ and $S$ by affine open neighbourhoods
of $x$ and $s$ which reduces us to the case that $X$ and $S$ are affine
(and hence $f$ of finite presentation).

\medskip\noindent
Choose a separable algebraic extension $\overline{k}$ of $\kappa(s)$.
Denote $X_{\overline{k}}$ the base change of $X_s$.
Choose a point $\overline{x}$ in $X_{\overline{k}}$ mapping to $x \in X_s$.
Choose a connected quasi-compact open neighbourhood
$\overline{V} \subset X_{\overline{k}}$
of $\overline{x}$. (This is possible because any scheme
locally of finite type over a field is locally connected
as a locally Noetherian topological space.)
By Varieties, Lemma \ref{varieties-lemma-Galois-action-quasi-compact-open}
we can find a finite separable extension $k'/\kappa(s)$
and a quasi-compact open $V' \subset X_{k'}$ whose
base change is $\overline{V}$. In particular $V'$ is
geometrically connected over $k'$, see
Varieties, Lemma \ref{varieties-lemma-characterize-geometrically-connected}. By
Lemma \ref{lemma-realize-prescribed-residue-field-extension-etale}
we can find an \'etale neighbourhood $(S', s') \to (S, s)$
such that $\kappa(s')$ is isomorphic to $k'$ as an extension
of $\kappa(s)$.
Denote $x' \in (S' \times_S X)_{s'} = X_{k'}$ the image of $\overline{x}$.
Thus after replacing $(S, s)$ by $(S', s')$ and $(X, x)$ by
$(S' \times_S X, x')$ we reduce to the case handled in the next
paragrah.

\medskip\noindent
Assume there is a quasi-compact open $V \subset X_s$
which contains $x$ and is geometrically irreducible.
Then we can apply Lemma \ref{lemma-fibre-geometrically-connected-reduced}
to find an affine \'etale neighbourhood $(S', s') \to (S, s)$
and a quasi-compact open $X' \subset S' \times_S X$ such that
$X' \to S'$ has geometrically connected fibres
and such that $X'$ contains a point mapping to $x$.
This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-normal-morphism-irreducible}
Let $h : Y \to S$ be a morphism of schemes.
Let $s \in S$ be a point.
Let $T \subset Y_s$ be an open subscheme.
Assume
\begin{enumerate}
\item $h$ is of finite presentation,
\item $h$ is normal, and
\item $T$ is geometrically irreducible over $\kappa(s)$.
\end{enumerate}
Then we can find an affine elementary \'etale neighbourhood
$(S', s') \to (S, s)$ and a quasi-compact open $V \subset Y_{S'}$ such that
\begin{enumerate}
\item[(a)] all fibres of $V \to S'$ are geometrically integral,
\item[(b)] $V_{s'} = T \times_s s'$.
\end{enumerate}
\end{lemma}

\begin{proof}
Apply
Lemma \ref{lemma-fibre-geometrically-connected-reduced}
to find an affine elementary \'etale neighbourhood $(S', s') \to (S, s)$ and
a quasi-compact open $V \subset Y_{S'}$ such that all fibres of
$V \to S'$ are geometrically connected and $V_{s'} = T \times_s s'$.
As $V$ is an open of the base change of $h$ all fibres of $V \to S'$
are geometrically normal, see Lemma \ref{lemma-normal}.
In particular, they are geometrically reduced. To finish the proof
we have to show they are geometrically irreducible. But, if $t \in S'$
then $V_t$ is of finite type over $\kappa(t)$ and hence
$V_t \times_{\kappa(t)} \overline{\kappa(t)}$ is of finite type
over $\overline{\kappa(t)}$ hence Noetherian. By choice of $S' \to S$
the scheme $V_t \times_{\kappa(t)} \overline{\kappa(t)}$ is connected.
Hence $V_t \times_{\kappa(t)} \overline{\kappa(t)}$ is irreducible by
Properties, Lemma \ref{properties-lemma-normal-Noetherian}
and we win.
\end{proof}








\section{Application to the structure of finite type morphisms}
\label{section-application-finite-type}

\noindent
The result in this section can be found in \cite{GruRay}.
Loosely stated it says that a finite type morphism is \'etale
locally on the source and target the composition of a finite
morphism by a smooth morphism with geometrically connected fibres
of relative dimension equal to the fibre dimension of the original
morphism.

\begin{lemma}
\label{lemma-local-structure-finite-type}
Let $f : X \to S$ be a morphism. Let $x \in X$ and set $s = f(x)$.
Assume that $f$ is locally of finite type and that $n = \dim_x(X_s)$.
Then there exists a commutative diagram
$$
\xymatrix{
X \ar[dd] & X' \ar[l]^g \ar[d]^\pi & x \ar@{|->}[dd] &
x' \ar@{|->}[l]  \ar@{|->}[d] \\
& Y \ar[d]^h & & y \ar@{|->}[d] \\
S \ar@{=}[r] & S & s & s \ar@{=}[l]
}
$$
and a point $x' \in X'$ with $g(x') = x$ such that with $y = \pi(x')$
we have
\begin{enumerate}
\item $h : Y \to S$ is smooth of relative dimension $n$,
\item $g : (X', x') \to (X, x)$ is an elementary \'etale neighbourhood,
\item $\pi$ is finite, and $\pi^{-1}(\{y\}) = \{x'\}$, and
\item $\kappa(y)$ is a purely transcendental extension of $\kappa(s)$.
\end{enumerate}
Moreover, if $f$ is locally of finite presentation then $\pi$ is
of finite presentation.
\end{lemma}

\begin{proof}
The problem is local on $X$ and $S$, hence we may assume that $X$ and
$S$ are affine. By
Algebra, Lemma \ref{algebra-lemma-refined-quasi-finite-over-polynomial-algebra}
after replacing $X$ by a standard open neighbourhood of $x$ in $X$
we may assume there is a factorization
$$
\xymatrix{
X \ar[r]^\pi & \mathbf{A}^n_S \ar[r] & S
}
$$
such that $\pi$ is quasi-finite and such that $\kappa(\pi(x))$
is purely transcendental over $\kappa(s)$. By
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}
there exists an elementary \'etale neighbourhood
$$
(Y, y) \to (\mathbf{A}^n_S, \pi(x))
$$
and an open $X' \subset X \times_{\mathbf{A}^n_S} Y$ which contains a
unique point $x'$ lying over $y$ such that $X' \to Y$ is finite.
This proves (1) -- (4) hold. For the final assertion, use
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}.
\end{proof}

\begin{lemma}
\label{lemma-local-local-structure-finite-type}
\begin{slogan}
A morphism of finite type is, in \'etale neighbourhoods, finite over a
smooth morphism.
\end{slogan}
Let $f : X \to S$ be a morphism. Let $x \in X$ and set $s = f(x)$.
Assume that $f$ is locally of finite type and that $n = \dim_x(X_s)$.
Then there exists a commutative diagram
$$
\xymatrix{
X \ar[dd] & X' \ar[l]^g \ar[d]^\pi & x \ar@{|->}[dd] &
x' \ar@{|->}[l] \ar@{|->}[d] \\
& Y' \ar[d]^h & & y' \ar@{|->}[d] \\
S & S' \ar[l]_e & s & s' \ar@{|->}[l]
}
$$
and a point $x' \in X'$ with $g(x') = x$ such that with $y' = \pi(x')$,
$s' = h(y')$ we have
\begin{enumerate}
\item $h : Y' \to S'$ is smooth of relative dimension $n$,
\item all fibres of $Y' \to S'$ are geometrically integral,
\item $g : (X', x') \to (X, x)$ is an elementary \'etale neighbourhood,
\item $\pi$ is finite, and $\pi^{-1}(\{y'\}) = \{x'\}$,
\item $\kappa(y')$ is a purely transcendental extension of $\kappa(s')$, and
\item $e : (S', s') \to (S, s)$ is an elementary \'etale neighbourhood.
\end{enumerate}
Moreover, if $f$ is locally of finite presentation, then $\pi$ is
of finite presentation.
\end{lemma}

\begin{proof}
The question is local on $S$, hence we may replace $S$ by an affine open
neighbourhood of $s$. Next, we apply
Lemma \ref{lemma-local-structure-finite-type}
to get a commutative diagram
$$
\xymatrix{
X \ar[dd] & X' \ar[l]^g \ar[d]^\pi & x \ar@{|->}[dd] &
x' \ar@{|->}[l] \ar@{|->}[d] \\
& Y \ar[d]^h & & y \ar@{|->}[d] \\
S \ar@{=}[r] & S & s & s \ar@{=}[l]
}
$$
where $h$ is smooth of relative dimension $n$ and $\kappa(y)$ is
a purely transcendental extension of $\kappa(s)$. Since the question is
local on $X$ also, we may replace $Y$ by an affine neighbourhood of $y$
(and $X'$ by the inverse image of this under $\pi$). As $S$ is affine
this guarantees that $Y \to S$ is quasi-compact, separated and smooth,
in particular of finite presentation.
Let $T$ be the connected component of $Y_s$ containing $y$.
As $Y_s$ is Noetherian we see that $T$ is open.
We also see that $T$ is geometrically connected over $\kappa(s)$ by
Varieties,
Lemma \ref{varieties-lemma-geometrically-connected-if-connected-and-point}.
Since $T$ is also smooth over $\kappa(s)$ it is geometrically normal, see
Varieties, Lemma \ref{varieties-lemma-smooth-geometrically-normal}.
We conclude that $T$ is geometrically irreducible over $\kappa(s)$ (as a
connected Noetherian normal scheme is irreducible, see
Properties, Lemma \ref{properties-lemma-normal-Noetherian}).
Finally, note that the smooth morphism $h$ is normal by
Lemma \ref{lemma-smooth-normal}.
At this point we have verified all assumption of
Lemma \ref{lemma-normal-morphism-irreducible}
hold for the morphism $h : Y \to S$ and open $T \subset Y_s$.
As a result of applying
Lemma \ref{lemma-normal-morphism-irreducible}
we obtain $e : S' \to S$, $s' \in S'$, $Y'$ as
in the commutative diagram
$$
\xymatrix{
X \ar[dd] & X' \ar[l]^g \ar[d]^\pi & X' \times_Y Y' \ar[l] \ar[d] &
x \ar@{|->}[dd] & x' \ar@{|->}[l] \ar@{|->}[d] &
(x', s') \ar@{|->}[l] \ar@{|->}[d] \\
& Y \ar[d]^h & Y' \ar[d] \ar[l] & & y \ar@{|->}[d] &
(y, s') \ar@{|->}[l] \ar@{|->}[d] \\
S \ar@{=}[r] & S & S' \ar[l]_e & s & s \ar@{=}[l] & s' \ar@{|->}[l]
}
$$
where $e : (S', s') \to (S, s)$ is an elementary \'etale neighbourhood,
and where $Y' \subset Y_{S'}$ is an open neighbourhood all of whose fibres
over $S'$ are geometrically irreducible, such that $Y'_{s'} = T$ via
the identification $Y_s = Y_{S', s'}$. Let $(y, s') \in Y'$ be the point
corresponding to $y \in T$; this is also the unique point of $Y \times_S S'$
lying over $y$ with residue field equal to $\kappa(y)$ which maps to $s'$
in $S'$. Similarly, let $(x', s') \in X' \times_Y Y' \subset X' \times_S S'$
be the unique point over $x'$ with residue field equal to $\kappa(x')$
lying over $s'$. Then the outer part of this diagram is a solution to the
problem posed in the lemma. Some minor details omitted.
\end{proof}

\begin{lemma}
\label{lemma-local-local-structure-finite-type-affine}
Assumption and notation as in
Lemma \ref{lemma-local-local-structure-finite-type}.
In addition to properties (1) -- (6) we may also arrange it so that
\begin{enumerate}
\item[(7)] $S'$, $Y'$, $X'$ are affine.
\end{enumerate}
\end{lemma}

\begin{proof}
Note that if $Y'$ is affine, then $X'$ is affine as $\pi$ is finite.
Choose an affine open neighbourhood $U' \subset S'$ of $s'$.
Choose an affine open neighbourhood $V' \subset h^{-1}(U')$ of $y'$.
Let $W' = h(V')$. This is an open neighbourhood of $s'$ in $S'$, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-open},
contained in $U'$. Choose an affine open neighbourhood $U'' \subset W'$
of $s'$. Then $h^{-1}(U'') \cap V'$ is affine because it is equal to
$U'' \times_{U'} V'$. By construction
$h^{-1}(U'') \cap V' \to U''$ is a surjective smooth morphism whose
fibres are (nonempty) open subschemes of geometrically integral fibres
of $Y' \to S'$, and hence geometrically integral. Thus we may replace
$S'$ by $U''$ and $Y'$ by $h^{-1}(U'') \cap V'$.
\end{proof}

\noindent
The significance of the property $\pi^{-1}(\{y'\}) = \{x'\}$ is partially
explained by the following lemma.

\begin{lemma}
\label{lemma-finite-morphism-single-point-in-fibre}
Let $\pi : X \to Y$ be a finite morphism.
Let $x \in X$ with $y = \pi(x)$ such that $\pi^{-1}(\{y\}) = \{x\}$.
Then
\begin{enumerate}
\item For every neighbourhood $U \subset X$ of $x$ in $X$, there
exists a neighbourhood $V \subset Y$ of $y$ such that
$\pi^{-1}(V) \subset U$.
\item The ring map $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$
is finite.
\item If $\pi$ is of finite presentation, then
$\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$ is of finite presentation.
\item For any quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$
we have $\mathcal{F}_x = \pi_*\mathcal{F}_y$ as
$\mathcal{O}_{Y, y}$-modules.
\end{enumerate}
\end{lemma}

\begin{proof}
The first assertion is purely topological; use that
$\pi$ is a continuous and closed map such that $\pi^{-1}(\{y\}) = \{x\}$.
To prove the second and third parts we may assume
$X = \Spec(B)$ and $Y = \Spec(A)$. Then
$A \to B$ is a finite ring map and $y$ corresponds to a prime
$\mathfrak p$ of $A$ such that there exists a unique prime $\mathfrak q$ of
$B$ lying over $\mathfrak p$. Then
$B_{\mathfrak q} = B_{\mathfrak p}$, see
Algebra, Lemma \ref{algebra-lemma-unique-prime-over-localize-below}.
In other words, the map $A_{\mathfrak p} \to B_{\mathfrak q}$
is equal to the map $A_{\mathfrak p} \to B_{\mathfrak p}$ you get
from localizing $A \to B$ at $\mathfrak p$.
Thus (2) and (3) follow from simple properties of localization
(some details omitted). For the final statement, suppose that
$\mathcal{F} = \widetilde M$ for some $B$-module $M$.
Then $\mathcal{F} = M_{\mathfrak q}$ and
$\pi_*\mathcal{F}_y = M_{\mathfrak p}$. By the above these
localizations agree. Alternatively you can use part (1) and
the definition of stalks to see that $\mathcal{F}_x = \pi_*\mathcal{F}_y$
directly.
\end{proof}






\section{Application to the fppf topology}
\label{section-application-fppf}

\noindent
We can use the above \'etale localization techniques to prove the
following result describing the fppf topology as being equal to
the topology ``generated by'' Zariski coverings and by coverings of the
form $\{f : T \to S\}$ where $f$ is surjective finite locally free.

\begin{lemma}
\label{lemma-dominate-fppf-etale-locally}
Let $S$ be a scheme. Let $\{S_i \to S\}_{i \in I}$ be an fppf covering.
Then there exist
\begin{enumerate}
\item an \'etale covering $\{S'_a \to S\}$,
\item surjective finite locally free morphisms $V_a \to S'_a$,
\end{enumerate}
such that the fppf covering $\{V_a \to S\}$ refines the given
covering $\{S_i \to S\}$.
\end{lemma}

\begin{proof}
We may assume that each $S_i \to S$ is locally quasi-finite, see
Lemma \ref{lemma-qf-fp-flat-dominates-fppf}.

\medskip\noindent
Fix a point $s \in S$. Pick an $i \in I$ and a point
$s_i \in S_i$ mapping to $s$. Choose an elementary \'etale neighbourhood
$(S', s) \to (S, s)$ such that there exists an open
$$
S_i \times_S S'  \supset V
$$
which contains a unique point $v \in V$ mapping to $s \in S'$
and such that $V \to S'$ is finite, see
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}.
Then $V \to S'$ is finite locally free, because it is finite
and because $S_i \times_S S' \to S'$ is flat and locally of finite presentation
as a base change of the morphism $S_i \to S$, see
Morphisms, Lemmas \ref{morphisms-lemma-base-change-finite-presentation},
\ref{morphisms-lemma-base-change-flat}, and
\ref{morphisms-lemma-finite-flat}.
Hence $V \to S'$ is open, and after shrinking $S'$
we may assume that $V \to S'$ is surjective finite locally free.
Since we can do this for every point of $S$ we conclude that
$\{S_i \to S\}$ can be refined by a covering of the form
$\{V_a \to S\}_{a \in A}$ where each $V_a \to S$ factors as
$V_a \to S'_a \to S$ with $S'_a \to S$ \'etale and $V_a \to S'_a$ surjective
finite locally free.
\end{proof}

\begin{lemma}
\label{lemma-dominate-fppf}
Let $S$ be a scheme. Let $\{S_i \to S\}_{i \in I}$ be an fppf covering.
Then there exist
\begin{enumerate}
\item a Zariski open covering $S = \bigcup U_j$,
\item surjective finite locally free morphisms $W_j \to U_j$,
\item Zariski open coverings $W_j = \bigcup_k W_{j, k}$,
\item surjective finite locally free morphisms $T_{j, k} \to W_{j, k}$
\end{enumerate}
such that the fppf covering $\{T_{j, k} \to S\}$ refines the given
covering $\{S_i \to S\}$.
\end{lemma}

\begin{proof}
Let $\{V_a \to S\}_{a \in A}$ be the fppf covering found in
Lemma \ref{lemma-dominate-fppf-etale-locally}.
In other words, this covering refines
$\{S_i \to S\}$
and each $V_a \to S$ factors as
$V_a \to S'_a \to S$ with $S'_a \to S$ \'etale and $V_a \to S'_a$
surjective finite locally free.

\medskip\noindent
By
Remark \ref{remark-topologies}
there exists a Zariski open covering $S = \bigcup U_j$,
for each $j$ a finite locally free, surjective morphism
$W_j \to U_j$, and for each $j$ a Zariski open covering
$\{W_{j, k} \to W_j\}$ such that the family
$\{W_{j, k} \to S\}$ refines the \'etale covering
$\{S'_a \to S\}$, i.e., for each pair $j, k$ there exists
an $a(j, k)$ and a factorization $W_{j, k} \to S'_a \to S$
of the morphism $W_{j, k} \to S$. Set
$T_{j, k} = W_{j, k} \times_{S'_a} V_a$ and everything is clear.
\end{proof}

\begin{lemma}
\label{lemma-extend-integral-surjective-morphisms}
Let $S$ be a scheme. If $U \subset S$ is open and $V \to U$ is a surjective
integral morphism, then there exists a surjective integral
morphism $\overline{V} \to S$ with $\overline{V} \times_S U$
isomorphic to $V$ as schemes over $U$.
\end{lemma}

\begin{proof}
Let $V' \to S$ be the normalization of $S$ in $U$, see
Morphisms, Section \ref{morphisms-section-normalization-X-in-Y}.
By construction $V' \to S$ is integral.
By Morphisms, Lemmas \ref{morphisms-lemma-normalization-localization} and
\ref{morphisms-lemma-normalization-in-integral} we see that
the inverse image of $U$ in $V'$ is $V$. Let $Z$ be the reduced
induced scheme structure on $S \setminus U$. Then
$\overline{V} = V' \amalg Z$ works.
\end{proof}

\begin{lemma}
\label{lemma-extend-finite-surjective-morphisms}
Let $S$ be a quasi-compact and quasi-separated scheme.
If $U \subset S$ is a quasi-compact open
and $V \to U$ is a surjective finite morphism, then there exists a
surjective finite morphism $\overline{V} \to S$ with $\overline{V} \times_S U$
isomorphic to $V$ as schemes over $U$.
\end{lemma}

\begin{proof}
By Zariski's Main Theorem
(Lemma \ref{lemma-quasi-finite-separated-pass-through-finite})
we can assume $V$ is a quasi-compact open in a scheme $V'$
finite over $S$. After replacing $V'$ by the scheme theoretic image
of $V$ we may assume that $V$ is dense in $V'$.
It follows that $V' \times_S U = V$ because $V \to V' \times_S U$
is closed as $V$ is finite over $U$. Let $Z$ be the reduced
induced scheme structure on $S \setminus U$. Then
$\overline{V} = V' \amalg Z$ works.
\end{proof}

\begin{lemma}
\label{lemma-dominate-fppf-integral}
Let $S$ be a scheme. Let $\{S_i \to S\}_{i \in I}$ be an fppf covering.
Then there exists a surjective integral morphism $S' \to S$ and an
open covering $S' = \bigcup U'_\alpha$ such that for each $\alpha$ the
morphism $U'_\alpha \to S$ factors through $S_i \to S$ for some $i$.
\end{lemma}

\begin{proof}
Choose $S = \bigcup U_j$, $W_j \to U_j$, $W_j = \bigcup W_{j, k}$, and
$T_{j, k} \to W_{j, k}$ as in Lemma \ref{lemma-dominate-fppf}.
By Lemma \ref{lemma-extend-integral-surjective-morphisms}
we can extend $W_j \to U_j$ to a surjective integral
morphism $\overline{W}_j \to S$.
After this we can extend $T_{j, k} \to W_{j, k}$ to a surjective
integral morphism $\overline{T}_{j, k} \to \overline{W}_j$.
We set $\overline{T}_j$ equal to the product of all the schemes
$\overline{T}_{j, k}$ over $\overline{W}_j$
(Limits, Lemma \ref{limits-lemma-infinite-product}).
Then we set $S'$ equal to the product of all the schemes
$\overline{T}_j$ over $S$.
If $x \in S'$, then there is a $j$ such that the image of $x$ in
$S$ lies in $U_j$. Hence there is a $k$ such that the image of
$x$ under the projection $S' \to \overline{W}_j$ lies in $W_{j, k}$.
Hence under the projection $S' \to \overline{T}_j \to \overline{T}_{j, k}$
the point $x$ ends up in $T_{j, k}$. And $T_{j, k} \to S$
factors through $S_i$ for some $i$.
Finally, the morphism $S' \to S$ is integral and surjective
by Limits, Lemmas \ref{limits-lemma-infinite-product-integral} and
\ref{limits-lemma-infinite-product-surjective}.
\end{proof}

\begin{lemma}
\label{lemma-dominate-fppf-finite}
Let $S$ be a quasi-compact and quasi-separated scheme.
Let $\{S_i \to S\}_{i \in I}$ be an fppf covering.
Then there exists a surjective finite morphism $S' \to S$
of finite presentation and an
open covering $S' = \bigcup U'_\alpha$ such that for each $\alpha$ the
morphism $U'_\alpha \to S$ factors through $S_i \to S$ for some $i$.
\end{lemma}

\begin{proof}
Let $Y \to X$ be the integral surjective morphism found in
Lemma \ref{lemma-dominate-fppf-integral}.
Choose a finite affine open covering $Y = \bigcup V_j$
such that $V_j \to X$ factors through $S_{i(j)}$.
We can write $Y = \lim Y_\lambda$ with
$Y_\lambda \to X$ finite and of finite presentation, see
Limits, Lemma \ref{limits-lemma-integral-limit-finite-and-finite-presentation}.
For large enough $\lambda$ we can find affine opens
$V_{\lambda, j} \subset Y_\lambda$
whose inverse image in $Y$ recovers $V_j$, see
Limits, Lemma \ref{limits-lemma-descend-opens}.
For even larger $\lambda$ the morphisms $V_j \to S_{i(j)}$
over $X$ come from morphisms $V_{\lambda, j} \to S_{i(j)}$ over
$X$, see
Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}.
Setting $S' = Y_\lambda$ for this $\lambda$ finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-fppf-ph}
An fppf covering of schemes is a ph covering.
\end{lemma}

\begin{proof}
Let $\{T_i \to T\}$ be an fppf covering of schemes, see
Topologies, Definition \ref{topologies-definition-fppf-covering}.
Observe that $T_i \to T$ is locally of finite type.
Let $U \subset T$ be an affine open.
It suffices to show that $\{T_i \times_T U \to U\}$
can be refined by a standard ph covering, see
Topologies, Definition \ref{topologies-definition-ph-covering}.
This follows immediately from Lemma \ref{lemma-dominate-fppf-finite}
and the fact that a finite morphism is proper
(Morphisms, Lemma \ref{morphisms-lemma-finite-proper}).
\end{proof}

\begin{remark}
\label{remark-change-topologies}
As a consequence of Lemma \ref{lemma-fppf-ph} we obtain a comparison morphism
$$
\epsilon : (\Sch/S)_{ph} \longrightarrow (\Sch/S)_{fppf}
$$
This is the morphism of sites given by the identity functor
on underlying categories (with suitable choices of sites
as in Topologies, Remark \ref{topologies-remark-choice-sites}).
The functor $\epsilon_*$ is the identity on underlying presheaves
and the functor $\epsilon^{-1}$ associated to an fppf sheaf
its ph sheafification.
By composition we can in addition compare the ph topology
with the syntomic, smooth, \'etale, and Zariski topologies.
\end{remark}




\section{Quasi-projective schemes}
\label{section-quasi-projective}

\noindent
The term ``quasi-projective scheme'' has not yet been defined.
A possible definition could be a scheme which has an ample invertible
sheaf. However, if $X$ is a scheme over a base scheme $S$, then
we say that {\it $X$ is quasi-projective over $S$} if the morphism
$X \to S$ is quasi-projective
(Morphisms, Definition \ref{morphisms-definition-quasi-projective}).
Since the identity morphism of any scheme is quasi-projective, we
see that a scheme quasi-projective over $S$ doesn't necessarily
have an ample invertible sheaf. For this reason it seems better to
leave the term ``quasi-projective scheme'' undefined.

\begin{lemma}
\label{lemma-quasi-projective}
Let $S$ be a scheme which has an ample invertible sheaf.
Let $f : X \to S$ be a morphism of schemes. The following are
equivalent
\begin{enumerate}
\item $X \to S$ is quasi-projective,
\item $X \to S$ is H-quasi-projective,
\item there exists a quasi-compact open immersion $X \to X'$ of schemes
over $S$ with $X' \to S$ projective,
\item $X \to S$ is of finite type and $X$ has an ample invertible
sheaf, and
\item $X \to S$ is of finite type and there exists an
$f$-very ample invertible sheaf.
\end{enumerate}
\end{lemma}

\begin{proof}
The implication (2) $\Rightarrow$ (1) is
Morphisms, Lemma \ref{morphisms-lemma-H-quasi-projective-quasi-projective}.
The implication (1) $\Rightarrow$ (2) is
Morphisms, Lemma
\ref{morphisms-lemma-projective-over-quasi-projective-is-H-projective}.
The implication (2) $\Rightarrow$ (3) is
Morphisms, Lemma \ref{morphisms-lemma-H-quasi-projective-open-H-projective}

\medskip\noindent
Assume $X \subset X'$ is as in (3). In particular $X \to S$ is
of finite type. By
Morphisms, Lemma \ref{morphisms-lemma-H-quasi-projective-open-H-projective}
the morphism $X \to S$ is H-projective.
Thus there exists a quasi-compact immersion $i : X \to \mathbf{P}^n_S$.
Hence $\mathcal{L} = i^*\mathcal{O}_{\mathbf{P}^n_S}(1)$
is $f$-very ample. As $X \to S$ is quasi-compact we conclude from
Morphisms, Lemma \ref{morphisms-lemma-ample-very-ample}
that $\mathcal{L}$ is $f$-ample. Thus $X \to S$ is quasi-projective
by definition.

\medskip\noindent
The implication (4) $\Rightarrow$ (2) is
Morphisms, Lemma \ref{morphisms-lemma-quasi-projective-finite-type-over-S}.

\medskip\noindent
Assume the equivalent conditions (1), (2), (3) hold.
Choose an immersion $i : X \to \mathbf{P}^n_S$ over $S$.
Let $\mathcal{L}$ be an ample invertible sheaf on $S$. To finish the
proof we will show that
$\mathcal{N} =
f^*\mathcal{L} \otimes_{\mathcal{O}_X} i^*\mathcal{O}_{\mathbf{P}^n_S}(1)$
is ample on $X$. By
Properties, Lemma \ref{properties-lemma-ample-on-locally-closed}
we reduce to the case $X = \mathbf{P}^n_S$. Let
$s \in \Gamma(S, \mathcal{L}^{\otimes d})$ be a section
such that the corresponding open $S_s$ is affine.
Say $S_s = \Spec(A)$.
Recall that $\mathbf{P}^n_S$ is the projective bundle
associated to $\mathcal{O}_S T_0 \oplus \ldots \oplus \mathcal{O}_S T_n$, see
Constructions, Lemma \ref{constructions-lemma-projective-space-bundle}
and its proof.
Let $s_i \in \Gamma(\mathbf{P}^n_S, \mathcal{O}(1))$
be the global section corresponding to the section $T_i$
of $\mathcal{O}_S T_0 \oplus \ldots \oplus \mathcal{O}_S T_n$.
Then we see that $X_{f^*s \otimes s_i^{\otimes n}}$ is affine
because it is equal to $\Spec(A[T_0/T_i, \ldots, T_n/T_i])$.
This proves that $\mathcal{N}$ is ample by definition.

\medskip\noindent
The equivalence of (1) and (5) follows from
Morphisms, Lemmas \ref{morphisms-lemma-ample-very-ample} and
\ref{morphisms-lemma-finite-type-ample-very-ample}.
\end{proof}

\begin{lemma}
\label{lemma-category-quasi-projective}
Let $S$ be a scheme which has an ample invertible sheaf.
Let $\text{QP}_S$ be the full subcategory of the
category of schemes over $S$ satisfying the equivalent
conditions of Lemma \ref{lemma-quasi-projective}.
\begin{enumerate}
\item if $S' \to S$ is a morphism of schemes and $S'$ has
an ample invertible sheaf, then base change determines
a functor $\text{QP}_S \to \text{QP}_{S'}$,
\item if $X \in \text{QP}_S$ and $Y \in \text{QP}_X$, then $Y \in \text{QP}_S$,
\item the category $\text{QP}_S$ is closed under fibre products,
\item the category $\text{QP}_S$ is closed under
finite disjoint unions,
\item if $X \to S$ is projective, then $X \in \text{QP}_S$,
\item if $X \to S$ is quasi-affine of finite type, then
$X$ is in $\text{QP}_S$,
\item if $X \to S$ is quasi-finite and separated, then
$X \in \text{QP}_S$,
\item if $X \to S$ is a quasi-compact immersion, then
$X \in \text{QP}_S$,
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from Morphisms, Lemma
\ref{morphisms-lemma-base-change-quasi-projective}.

\medskip\noindent
Part (2) follows from the fourth characterization of
Lemma \ref{lemma-quasi-projective}.

\medskip\noindent
If $X \to S$ and $Y \to S$ are quasi-projective, then
$X \times_S Y \to Y$ is quasi-projective by
Morphisms, Lemma \ref{morphisms-lemma-base-change-quasi-projective}.
Hence (3) follows from (2).

\medskip\noindent
If $X = Y \amalg Z$ is a disjoint union of schemes
and $\mathcal{L}$ is an invertible $\mathcal{O}_X$-module
such that $\mathcal{L}|_Y$ and $\mathcal{L}|_Z$ are ample, then
$\mathcal{L}$ is ample (details omitted). Thus
part (4) follows from the fourth characterization of
Lemma \ref{lemma-quasi-projective}.

\medskip\noindent
Part (5) follows from
Morphisms, Lemma \ref{morphisms-lemma-projective-quasi-projective}.

\medskip\noindent
Part (6) follows from
Morphisms, Lemma
\ref{morphisms-lemma-quasi-affine-finite-type-quasi-projective}.

\medskip\noindent
Part (7) follows from part (6) and
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.

\medskip\noindent
Part (8) follows from part (7) and
Morphisms, Lemma \ref{morphisms-lemma-immersion-locally-quasi-finite}.
\end{proof}

\noindent
The following lemma doesn't really belong in this section, but
there does not seem to be a good spot for it anywhere else.

\begin{lemma}
\label{lemma-integral-over-quasi-affine}
Let $X$ be a quasi-affine scheme. Let $f : U \to X$ be an integral
morphism. Then $U$ is quasi-affine and the diagram
$$
\xymatrix{
U \ar[r] \ar[d] & \Spec(\Gamma(U, \mathcal{O}_U)) \ar[d] \\
X \ar[r] & \Spec(\Gamma(X, \mathcal{O}_X))
}
$$
is cartesian.
\end{lemma}

\begin{proof}
The scheme $U$ is quasi-affine because integral morphisms are affine,
affine morphisms are quasi-affine, a scheme is quasi-affine if and only if
the structure morphism to $\Spec(\mathbf{Z})$ is quasi-affine, and
compositions of quasi-affine morphisms are quasi-affine.
The first two statements follow immediately from the definition
and the third is
Morphisms, Lemma \ref{morphisms-lemma-composition-quasi-affine}.
Set $U' =
X \times_{\Spec(\Gamma(X, \mathcal{O}_X))} \Spec(\Gamma(U, \mathcal{O}_U))$
and consider the extended diagram
$$
\xymatrix{
U \ar[r]_j \ar[rd] & U' \ar[d] \ar[r] &
\Spec(\Gamma(U, \mathcal{O}_U)) \ar[d] \\
& X \ar[r] & \Spec(\Gamma(X, \mathcal{O}_X))
}
$$
The morphism $j$ is closed by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}
combined with the fact that an integral morphism is universally closed
(Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed})
and the fact that the vertical arrows are in the diagram are separated.
On the other hand, $j$ is open because the horizontal
arrows in the diagram of the lemma are open by
Properties, Lemma \ref{properties-lemma-quasi-affine}.
Thus $j$ identifies $U$ with an open and closed subscheme of $U'$.
If $U \not = U'$ then $U$ isn't dense in $U'$ and a fortiori
not dense in the spectrum of $\Gamma(U, \mathcal{O}_U)$.
However, the scheme theoretic image of
$U$ in $\Spec(\Gamma(U, \mathcal{O}_U))$ is $\Spec(\Gamma(U, \mathcal{O}_U))$
because any ideal in $\Gamma(U, \mathcal{O}_U)$
cutting out a closed subscheme through which $U$
factors would have to be zero.
Hence $U$ is dense in $\Spec(\Gamma(U, \mathcal{O}_U))$ for example by
Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-scheme-theoretic-image}.
Thus $U = U'$ and we win.
\end{proof}









\section{Projective schemes}
\label{section-projective}

\noindent
This section is the analogue of Section \ref{section-quasi-projective}
for projective morphisms.

\begin{lemma}
\label{lemma-projective}
Let $S$ be a scheme which has an ample invertible sheaf.
Let $f : X \to S$ be a morphism of schemes. The following are
equivalent
\begin{enumerate}
\item $X \to S$ is projective,
\item $X \to S$ is H-projective,
\item $X \to S$ is quasi-projective and proper,
\item $X \to S$ is H-quasi-projective and proper,
\item $X \to S$ is proper and $X$ has an ample invertible sheaf,
\item $X \to S$ is proper and there exists an $f$-ample invertible sheaf,
\item $X \to S$ is proper and there exists an $f$-very ample invertible sheaf,
\item there is a quasi-coherent graded $\mathcal{O}_S$-algebra $\mathcal{A}$
generated by $\mathcal{A}_1$ over $\mathcal{A}_0$ with $\mathcal{A}_1$ a
finite type $\mathcal{O}_S$-module such that
$X = \underline{\text{Proj}}_S(\mathcal{A})$. 
\end{enumerate}
\end{lemma}

\begin{proof}
Observe first that in each case the morphism $f$ is proper, see
Morphisms, Lemmas \ref{morphisms-lemma-H-projective} and
\ref{morphisms-lemma-locally-projective-proper}.
Hence it suffices to prove the equivalence of the notions in
case $f$ is a proper morphism. We will use this without further
mention in the following.

\medskip\noindent
The equivalences (1) $\Leftrightarrow$ (3) and
(2) $\Leftrightarrow$ (4) are
Morphisms, Lemma \ref{morphisms-lemma-projective-is-quasi-projective-proper}.

\medskip\noindent
The implication (2) $\Rightarrow$ (1) is
Morphisms, Lemma \ref{morphisms-lemma-H-projective}.

\medskip\noindent
The implications (1) $\Rightarrow$ (2) and (3) $\Rightarrow$ (4) are
Morphisms, Lemma
\ref{morphisms-lemma-projective-over-quasi-projective-is-H-projective}.

\medskip\noindent
The implication (1) $\Rightarrow$ (7) is immediate from
Morphisms, Definitions \ref{morphisms-definition-projective} and
\ref{morphisms-definition-very-ample}.

\medskip\noindent
The conditions (3) and (6) are equivalent by
Morphisms, Definition \ref{morphisms-definition-quasi-projective}.

\medskip\noindent
Thus (1) -- (4), (6) are equivalent and imply (7). By
Lemma \ref{lemma-quasi-projective}
conditions (3), (5), and (7) are equivalent.
Thus we see that (1) -- (7) are equivalent.

\medskip\noindent
By Divisors, Lemma \ref{divisors-lemma-relative-proj-projective}
we see that (8) implies (1). Conversely, if (2) holds, then
we can choose a closed immersion
$$
i :
X
\longrightarrow
\mathbf{P}^n_S = \underline{\text{Proj}}_S(\mathcal{O}_S[T_0, \ldots, T_n]).
$$
See Constructions, Lemma \ref{constructions-lemma-projective-space-bundle}
for the equality. By
Divisors, Lemma \ref{divisors-lemma-closed-subscheme-proj}
we see that $X$ is the relative Proj of a quasi-coherent graded quotient
algebra $\mathcal{A}$ of $\mathcal{O}_S[T_0, \ldots, T_n]$.
Then $\mathcal{A}$ satisfies the conditions of (8).
\end{proof}

\begin{lemma}
\label{lemma-category-projective}
Let $S$ be a scheme which has an ample invertible sheaf.
Let $\text{P}_S$ be the full subcategory of the
category of schemes over $S$ satisfying the equivalent
conditions of Lemma \ref{lemma-projective}.
\begin{enumerate}
\item if $S' \to S$ is a morphism of schemes and $S'$ has
an ample invertible sheaf, then base change determines
a functor $\text{P}_S \to \text{P}_{S'}$,
\item if $X \in \text{P}_S$ and $Y \in \text{P}_X$, then $Y \in \text{P}_S$,
\item the category $\text{P}_S$ is closed under fibre products,
\item the category $\text{P}_S$ is closed under
finite disjoint unions,
\item if $X \to S$ is finite, then $X$ is in $\text{P}_S$,
\item add more here.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from Morphisms, Lemma
\ref{morphisms-lemma-base-change-projective}.

\medskip\noindent
Part (2) follows from the fifth characterization of
Lemma \ref{lemma-projective} and the fact that compositions
of proper morphisms are proper
(Morphisms, Lemma \ref{morphisms-lemma-composition-proper}).

\medskip\noindent
If $X \to S$ and $Y \to S$ are projective, then
$X \times_S Y \to Y$ is projective by
Morphisms, Lemma \ref{morphisms-lemma-base-change-projective}.
Hence (3) follows from (2).

\medskip\noindent
If $X = Y \amalg Z$ is a disjoint union of schemes
and $\mathcal{L}$ is an invertible $\mathcal{O}_X$-module
such that $\mathcal{L}|_Y$ and $\mathcal{L}|_Z$ are ample, then
$\mathcal{L}$ is ample (details omitted). Thus
part (4) follows from the fifth characterization of
Lemma \ref{lemma-projective}.

\medskip\noindent
Part (5) follows from
Morphisms, Lemma \ref{morphisms-lemma-finite-projective}.
\end{proof}

\noindent
Here is a slightly different type of result.

\begin{lemma}
\label{lemma-ample-in-neighbourhood}
\begin{reference}
\cite[IV Corollary 9.6.4]{EGA}
\end{reference}
Let $f : X \to Y$ be a proper morphism of schemes.
Let $\mathcal{L}$ be an invertible $\mathcal{O}_X$-module.
Let $y \in Y$ be a point such that $\mathcal{L}_y$ is ample
on $X_y$. Then there is an open neighbourhood $V \subset Y$
of $y$ such that $\mathcal{L}|_{f^{-1}(V)}$ is ample on $f^{-1}(V)/V$.
\end{lemma}

\begin{proof}
We may assume $Y$ is affine. Then we find a directed set $I$
and an inverse system of morphisms $X_i \to Y_i$ of schemes
with $Y_i$ of finite type over $\mathbf{Z}$, with affine
transition morphisms $X_i \to X_{i'}$ and $Y_i \to Y_{i'}$,
with $X_i \to Y_i$ proper, such that $X \to Y = \lim (X_i \to Y_i)$.
See Limits, Lemma
\ref{limits-lemma-proper-limit-of-proper-finite-presentation-noetherian}.
After shrinking $I$ we can assume we have a compatible system of
invertible $\mathcal{O}_{X_i}$-modules $\mathcal{L}_i$
pulling back to $\mathcal{L}$, see
Limits, Lemma \ref{limits-lemma-descend-invertible-modules}.
Let $y_i \in Y_i$ be the image of $y$.
Then $\kappa(y) = \colim \kappa(y_i)$.
Hence for some $i$ we have $\mathcal{L}_{i, y_i}$
is ample on $X_{i, y_i}$ by
Limits, Lemma \ref{limits-lemma-limit-ample}.
By Cohomology of Schemes, Lemma \ref{coherent-lemma-ample-in-neighbourhood}
we find an open neigbourhood
$V_i \subset Y_i$ of $y_i$ such that
$\mathcal{L}_i$ restricted to $f_i^{-1}(V_i)$
is ample relative to $V_i$.
Letting $V \subset Y$ be the inverse image of
$V_i$ finishes the proof (hints: use
Morphisms, Lemma \ref{morphisms-lemma-ample-base-change} and
the fact that $X \to Y \times_{Y_i} X_i$ is affine
and the fact that the pullback of an
ample invertible sheaf by an affine morphism is ample by
Morphisms, Lemma \ref{morphisms-lemma-pullback-ample-tensor-relatively-ample}).
\end{proof}







\section{Proj and Spec}
\label{section-proj-spec}

\noindent
In this section we clarify the relationship between the Proj and the spectrum
of a graded ring.

\medskip\noindent
Let $R$ be a ring. Let $A$ be a graded $R$-algebra, see
Algebra, Section \ref{algebra-section-graded}.
For $m \geq 0$ we denote $A_{\geq m} = \bigoplus_{d \geq m} A_d$.
Consider the graded ring
$$
B = \bigoplus\nolimits_{d \geq 0} A_{\geq d}
$$
For $d' \geq d$ and $a \in A_{d'}$ let us denote $a^{(d)} \in B$
the element in $B_d$ corresponding to $a$.
Let us denote $\sigma : A \to B$ and $\psi : A \to B$
the two obvious ring maps: if $a \in A_d$, then
$\sigma(a) = a^{(0)}$ and $\psi(a) = a^{(d)}$.
Then $\psi$ is a graded ring map and $\sigma$ turns $B$
into a graded algebra over $A$. There is also a
surjective graded ring map $\tau : B \to A$
which for $d' \geq d$ and $a \in A_{d'}$ sends
$a^{(d)}$ to $0$ if $d' > d$ and to $a$ if $d' = d$.

\medskip\noindent
Affine schemes and spectra.
We set $X = \Spec(A)$. The irrelevant ideal $A_+$ cuts out a closed subscheme
$Z = V(A_+) = \Spec(A/A_+) = \Spec(A_0)$. Set $U = X \setminus Z$.
$$
U \longrightarrow X \longrightarrow Z
$$
Projective schemes and Proj. Set $P = \text{Proj}(A)$. We may
and do view $P$ as a scheme over $\Spec(A_0) = Z$.
Set $L = \text{Proj}(B)$. We may and do view $L$ as a scheme
over $\Spec(B_0) = \Spec(A) = X$; observe that the identification
of $B_0$ with $A$ is given by $\sigma$.
The surjection $\tau$ defines a closed immersion $0 : P \to L$.
Since $A \xrightarrow{\sigma} B \to A$ is equal to the map $A \to A_0 \to A$
we conclude that
$$
\xymatrix{
P \ar[d] \ar[r]_0 & L \ar[d] \\
Z \ar[r] & X
}
$$
is commutative.

\medskip\noindent
We claim that $\psi$ defines a morphism $L \to P$.
To see this, by Constructions, Lemma \ref{constructions-lemma-morphism-proj},
it suffices to check $\psi(A_+) \not \subset \mathfrak p$ for
every homogeneous prime ideal
$\mathfrak p \subset B$ with $B_+ \not \subset \mathfrak p$.
First, pick $g \in B_+$ homogeneous $g \not \in \mathfrak p$.
Then we can write $g$ as a finite sum $g = \sum a_i^{(d)}$
with $a_i \in A_{d_i}$ for some $d_i \geq d$.
We conclude that there exist $d' \geq d$ and $a \in A_{d'}$
such that $a^{(d)} \not \in \mathfrak p$.
Then
$$
(a^{(d)})^{d'} =
(a^{d'})^{(d'd)} =
a^{(d)} (a^{d' - 1})^{(d(d' - 1))} =
\psi(a) (a^{d' - 1})^{(d(d' - 1))}
$$
(the notation leaves something to be desired) is not in $\mathfrak p$.
Hence $\psi(a) \not \in \mathfrak p$, proving the claim.
Thus we can extend our diagram above to a commutative diagram
$$
\xymatrix{
P \ar[d] \ar[r]_0 & L \ar[d] \ar[r]_\pi & P \ar[d] \\
Z \ar[r] & X \ar[r] & Z
}
$$
where $X \to Z$ is given by $A_0 \to A$.
Since $\tau \circ \psi = \text{id}_A$ we see $\pi \circ 0 = \text{id}_P$.

\medskip\noindent
Observe that $\pi$ is an affine morphism. This is clear from the construction
in Constructions, Lemma \ref{constructions-lemma-morphism-proj}. In fact, if
$f \in A_d$ for some $d > 0$, then
setting $g = \psi(f)$ we have $\pi^{-1}(D_+(f)) = D_+(g)$.
In this case we have the following equality of homogeneous parts
$$
(B[1/g])_{m'} = \bigoplus\nolimits_{m \geq m'} (A[1/f])_m
$$
This isomorphism is compatible with further localization.
Taking $m' = 0$ we see that $\pi_*\mathcal{O}_L$ is the
direct sum of $\mathcal{O}_P(m)$ for $m \geq 0$\footnote{It similarly follows
that $\pi_*\mathcal{O}_L(i) = \bigoplus_{m \geq -i} \mathcal{O}_P(m)$.}.
We conclude $L$ is idendified with the relative spectrum:
$$
L = \underline{\Spec}_P
\left(
\bigoplus\nolimits_{m \geq 0} \mathcal{O}_P(m)
\right)
$$
In particular $L \to P$ is a cone\footnote{Often $L$ is a line bundle
over $P$, see below.}, see
Constructions, Section \ref{constructions-section-cone}.
Moreover, it is clear that $0 : P \to L$ is the vertex of the cone.

\medskip\noindent
Let $f \in A_d$ for some $d > 0$ and $g = \psi(f) \in B_d$
as in the previous paragraph. Looking at the structure of the ring maps
$$
\xymatrix{
A_0 \ar[r] \ar[d] & A \ar[d]^\sigma \ar[r] & A_0 \ar[d] \\
(A[1/f])_0 \ar[r]^-\psi &
(B[1/g])_0 = \bigoplus\nolimits_{m \geq 0} (A[1/f])_m
\ar[r]^-\tau &
(A[1/f])_0
}
$$
some compuations\footnote{Parts (1) and (2) are clear.
To see (3), note that if $a \in A_d$, then
$\sigma(a) = \sigma(f) \psi(a/f)$. For (4) note that
$b/g^m$ is in the kernel of $\tau$ if and only if
$b \in A_{\geq md}$ maps to zero in $A_{md}$.
Thus it suffices to show if $m' > md$ and $a \in A_{m'}$,
then some power of $a^{(md)}/g^m$ is in the ideal generated by
$\sigma(f)$. Take $e$ such that $em' - emd \geq d$. Then
$$
(a^{(md)}/g^m)^e = (a^e)^{(emd)}/g^{em} =
(fa^e)^{(emd + d)}/g^{em + 1} = \sigma(f) \cdot (a^e)^{(emd + d)}/g^{em + 1}
$$
as desired (apologies for the terrible notation). To see (5) argue as
before and note that $a^{(md)}/g^m = \sigma(f) \cdot a^{(md + 1)}/g^{m + 1}$
if $d = 1$.}
in graded rings will show that
\begin{enumerate}
\item $\sigma(A_+)(B[1/g])_0 \subset \Ker(\tau : (B[1/g])_0 \to (A[1/f])_0)$,
\item $\sigma(f) \in (B[1/g])_0$ is a nonzerodivisor,
\item $\sigma(f) (B[1/g])_0 = \sigma(A_d) (B[1/g])_0$ as ideals,
\item $\sigma(f) (B[1/g])_0$ and
$\Ker(\tau : (B[1/g])_0 \to (A[1/f])_0)$ have the same radical,
\item if $d = 1$, then
$\sigma(f) (B[1/g])_0 = \Ker(\tau : (B[1/g])_0 \to (A[1/f])_0)$.
\end{enumerate}
We see in particular that
$$
0(D_+(f)) = V(\sigma(f)) \subset D_+(g) = \Spec((B[1/g])_0)
$$
set theoretically. In other words, the ideal generated by
$\sigma(A_d)$ cuts out an effective Cartier divisor on
$D_+(g)$ which is set theoretically
equal to the image of the closed immersion $0 : P \to L$.

\medskip\noindent
We claim that $L \to X$ is an isomorphism over $U$.
Namely, if $f \in A_d$ for some $d > 0$, then
$$
\Spec(A_f) \times_X L = \text{Proj}(A_f \otimes_A B) =
\text{Proj}(B_{\sigma(f)})
$$
For each $e$ we have
$(B_{\sigma(f)})_e = A_f \otimes_B B_e = A_f \otimes_A A_{\geq e} = A_f$,
the final equality induced by the injection $A_{\geq e} \subset A$.
Hence $B_{\sigma(f)} \cong A_f[T]$ with $T$ in degree $1$.
This proves the claim as $\text{Proj}(A_f[T]) \to \Spec(A_f)$
is an isomorphism. From now on we identify $U$ with the corresponding
open of $L$.

\medskip\noindent
The identification made in the previous paragraph lets us
consider the restriction $\pi|_U : U \to P$. Pick 
$f \in A_d$ for some $d > 0$ and $g = \psi(f) \in B_d$
as we have done above several times. Then
$$
U \cap \pi^{-1}(D_+(f)) = U \cap D_+(g)
$$
is the complement of the zero locus of $\sigma(f) \in (B[1/g])_0$
via the identification of $D_+(g)$ with the spectrum of $(B[1/g])_0$.
This is assertion (4) above. Therefore
$U \cap D_+(g)$ is affine and
$$
\mathcal{O}_L(U \cap D_+(g)) = (B[1/g])_0[1/\sigma(f)] =
\bigoplus\nolimits_{m \in \mathbf{Z}} (A[1/f])_m
$$
where the last equal sign is the natural extension of
the identification $(B[1/g])_0 = \bigoplus_{m \geq 0} (A[1/f])_m$
made above. Exactly as we did before with $\pi : L \to P$
we conclude that $\pi|_U : U \to P$ is affine and
$$
U = \underline{\Spec}_P
\left(
\bigoplus\nolimits_{m \in \mathbf{Z}} \mathcal{O}_P(m)
\right)
$$
as schemes over $P$.

\medskip\noindent
Summarising the above, our constructions produce a commutative diagram
\begin{equation}
\label{equation-proj-and-spec}
\vcenter{
\xymatrix{
\underline{\Spec}_P \left(
\bigoplus\nolimits_{m \in \mathbf{Z}} \mathcal{O}_P(m)
\right)
\ar[r] \ar@{=}[d] &
L =
\underline{\Spec}_P \left(
\bigoplus\nolimits_{m \geq 0} \mathcal{O}_P(m)
\right) \ar[d]^\sigma \ar[r]_-\pi & P \ar[d] \\
U \ar[r] & X \ar[r] & Z
}
}
\end{equation}
of schemes where $\pi$ is a cone whose zero section $0 : P \to L$
maps set theoretically onto the inverse image of $Z$ in $L$.

\medskip\noindent
Let $W \subset P$ be the largest open such that $\mathcal{O}_P(1)|_W$
is invertible and the natural maps induce isomorphisms
$\mathcal{O}_P(m)|_W \cong \mathcal{O}_P(1)^{\otimes m}|_W$
for all $m \in \mathbf{Z}$, i.e., the open of
Constructions, Lemma \ref{constructions-lemma-where-invertible} for $d = 1$.
Then we see that $L|_W = \pi^{-1}(W) \to W$ is a vector bundle
(Constructions, Section \ref{constructions-section-vector-bundle})
of rank $1$, namely,
$$
L|_W = \mathbf{V}(\mathcal{O}_P(1)|_W)
$$
in Grothendieckian notation. This is immediate from the above showing
that $L|_W$ is equal to the relative spectrum of the symmetric algebra over
$\mathcal{O}_W$ on $\mathcal{O}_P(1)|_W$. Then clearly the
morphism $0|_W : W \to L|_W$ is the zero section of this
vector bundle. In particular $0(W)$ is an effective Cartier divisor
on $L|_W$. Moreover, the open $U|_W = (\pi|_U)^{-1}(W)$
is the complement of the zero section.

\medskip\noindent
If $A$ is generated by $f_1, \ldots, f_r \in A_1$ over $A_0$, then
$(f_1, \ldots, f_r)^m = A_{\geq m}$ for all $m \geq 0$ and hence our
$B$ above is the Rees algebra for $A_+ = (f_1, \ldots, f_r)$. Thus in this
case $L \to X$ is the blowup of $Z$ and $W = P$ where $W$ is as in
the preceding paragraph.

\medskip\noindent
If $P$ is quasi-compact, then for $d$ sufficiently divisible, the
closed subscheme $D \subset L$ cut out by $\sigma(A_d)\mathcal{O}_L$
is an effective Cartier divisor, $0 : P \to L$ factors through $D$,
and $0(P) = D$ set theoretically. This follows from
Constructions, Lemma \ref{constructions-lemma-proj-quasi-compact}
and (1), (2), (3), and (4) proved above. (Take any $d$ divisible by the
lcm of the degrees of the elements found in the lemma.)

\medskip\noindent
We continue to assume $P$ is quasi-compact.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_P$-module.
Let us set $\mathcal{F}_U = \pi^*\mathcal{F}|_U$. Then we have
\begin{equation}
\label{equation-cohomology-torsor}
R\Gamma(U, \mathcal{F}_U) =
\bigoplus\nolimits_{m \in \mathbf{Z}}
R\Gamma(P, \mathcal{F} \otimes_{\mathcal{O}_P} \mathcal{O}_P(m))
\end{equation}
Moreover, this direct sum decomposition is functorial in $\mathcal{F}$
and the induced $A$-module structure on the right is the same as the
$A$-module structure on the left coming from $U \subset X$.
To prove the formula, since $\pi|_U$ is affine and
$(\pi|_U)_*\mathcal{O}_U = \bigoplus_{m \in \mathbf{Z}} \mathcal{O}_P(m)$
we get
\begin{align*}
R(\pi|_U)_*\mathcal{F}_U
& =
(\pi|_U)_*\mathcal{F}_U \\
& =
(\pi|_U)_*(\pi|_U)^*\mathcal{F} \\
& =
\mathcal{F} \otimes_{\mathcal{O}_P} 
\bigoplus\nolimits_{m \in \mathbf{Z}} \mathcal{O}_P(m) \\
& =
\bigoplus\nolimits_{m \in \mathbf{Z}}
\mathcal{F} \otimes_{\mathcal{O}_P} \mathcal{O}_P(m)
\end{align*}
By Leray we find that
$R\Gamma(U, \mathcal{F}_U) =
R\Gamma(P, R(\pi|_U)_*\mathcal{F}_U)$, see
Cohomology, Lemma \ref{cohomology-lemma-apply-Leray}.
The proof is finished because taking cohomology commutes with
direct sums in this case, see Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-pushforward-direct-sums}.
This is where we use that $P$ is quasi-compact; $P$ is separated
by Constructions, Lemma \ref{constructions-lemma-proj-separated}.

\begin{lemma}
\label{lemma-apply-proj-spec}
Let $R$ be a ring. Let $P$ be a proper scheme over $R$ and let
$\mathcal{L}$ be an ample invertible $\mathcal{O}_P$-module.
Set $A = \bigoplus_{m \geq 0} \Gamma(P, \mathcal{L}^{\otimes m})$.
Then $P = \text{Proj}(A)$ and diagram (\ref{equation-proj-and-spec})
becomes the diagram
$$
\xymatrix{
\underline{\Spec}_P \left(
\bigoplus\nolimits_{m \in \mathbf{Z}} \mathcal{L}^{\otimes m}
\right)
\ar[r] \ar@{=}[d] &
L =
\underline{\Spec}_P \left(
\bigoplus\nolimits_{m \geq 0} \mathcal{L}^{\otimes m}
\right) \ar[d]^\sigma \ar[r]_-\pi & P \ar[d] \\
U \ar[r] & X \ar[r] & Z
}
$$
having the properties explained above.
\end{lemma}

\begin{proof}
We have $P = \text{Proj}(A)$ by
Morphisms, Lemma \ref{morphisms-lemma-proper-ample-is-proj}.
Moreover, by Properties, Lemma \ref{properties-lemma-ample-gcd-is-one}
via this identification we have $\mathcal{O}_P(m) = \mathcal{L}^{\otimes m}$
for all $m \in \mathbf{Z}$.
\end{proof}









\section{Closed points in fibres}
\label{section-closed-points-fibres}

\noindent
Some of the material in this section is taken from the preprint
\cite{Osserman-Payne}.

\begin{lemma}
\label{lemma-locally-principal-vertical}
Let $f : X \to S$ be a morphism of schemes.
Let $Z \subset X$ be a closed subscheme.
Let $s \in S$.
Assume
\begin{enumerate}
\item $S$ is irreducible with generic point $\eta$,
\item $X$ is irreducible,
\item $f$ is dominant,
\item $f$ is locally of finite type,
\item $\dim(X_s) \leq \dim(X_\eta)$,
\item $Z$ is locally principal in $X$, and
\item $Z_\eta = \emptyset$.
\end{enumerate}
Then the fibre $Z_s$ is (set theoretically) a union of
irreducible components of $X_s$.
\end{lemma}

\begin{proof}
Let $X_{red}$ denote the reduction of $X$. Then $Z \cap X_{red}$ is
a locally principal closed subscheme of $X_{red}$, see
Divisors, Lemma \ref{divisors-lemma-pullback-locally-principal}.
Hence we may assume that $X$ is reduced. In other words $X$ is integral, see
Properties, Lemma \ref{properties-lemma-characterize-integral}.
In this case the morphism $X \to S$ factors through $S_{red}$, see
Schemes, Lemma \ref{schemes-lemma-map-into-reduction}.
Thus we may replace $S$ by $S_{red}$ and assume that $S$ is integral too.

\medskip\noindent
The assertion that $f$ is dominant signifies that the generic point of $X$
is mapped to $\eta$, see
Morphisms,
Lemma \ref{morphisms-lemma-dominant-finite-number-irreducible-components}.
Moreover, the scheme $X_\eta$ is an integral scheme which is locally of
finite type over the field $\kappa(\eta)$. Hence
$d = \dim(X_\eta) \geq 0$ is equal to $\dim_\xi(X_\eta)$ for
every point $\xi$ of $X_\eta$, see
Algebra, Lemmas \ref{algebra-lemma-dimension-spell-it-out} and
\ref{algebra-lemma-dimension-at-a-point-finite-type-over-field}.
In view of
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}
and condition (5) we conclude that $\dim_x(X_s) = d$
for every $x \in X_s$.

\medskip\noindent
In the Noetherian case the assertion can be proved as follows.
If the lemma does not holds there exists $x \in Z_s$ which is a generic
point of an irreducible component of $Z_s$ but not a generic point
of any irreducible component of $X_s$. Then we see that
$\dim_x(Z_s) \leq d - 1$, because $\dim_x(X_s) = d$ and in a neighbourhood
of $x$ in $X_s$ the closed subscheme $Z_s$ does not contain any of the
irreducible components of $X_s$. Hence after replacing $X$ by an
open neighbourhood of $x$ we may assume that
$\dim_z(Z_{f(z)}) \leq d - 1$ for all $z \in Z$, see
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}.
Let $\xi' \in Z$ be a generic point of an irreducible component of $Z$
and set $s' = f(\xi)$. As $Z \not = X$ is locally principal we see that
$\dim(\mathcal{O}_{X, \xi}) = 1$, see
Algebra, Lemma \ref{algebra-lemma-minimal-over-1}
(this is where we use $X$ is Noetherian).
Let $\xi \in X$ be the generic point of $X$ and
let $\xi_1$ be a generic point of any irreducible component
of $X_{s'}$ which contains $\xi'$. Then we see that we have
the specializations
$$
\xi \leadsto \xi_1 \leadsto \xi'.
$$
As $\dim(\mathcal{O}_{X, \xi}) = 1$ one of the two specializations
has to be an equality.
By assumption $s' \not = \eta$, hence the first specialization
is not an equality.
Hence $\xi' = \xi_1$ is a generic point of an irreducible component of
$X_{s'}$. Applying
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}
one more time this implies
$\dim_{\xi'}(Z_{s'}) = \dim_{\xi'}(X_{s'}) \geq \dim(X_\eta) = d$
which gives the desired contradiction.

\medskip\noindent
In the general case we reduce to the Noetherian case as follows.
If the lemma is false then there exists a point
$x \in X$ lying over $s$ such that $x$ is a generic point of an
irreducible component of $Z_s$, but
not a generic point of any of the irreducible components of $X_s$.
Let $U \subset S$ be an affine neighbourhood of $s$ and let
$V \subset X$ be an affine neighbourhood of $x$ with $f(V) \subset U$.
Write $U = \Spec(A)$ and $V = \Spec(B)$ so that $f|_V$
is given by a ring map $A \to B$. Let $\mathfrak q \subset B$,
resp.\ $\mathfrak p \subset A$ be the prime corresponding to $x$, resp.\ $s$.
After possibly shrinking $V$ we may assume $Z \cap V$ is cut out by
some element $g \in B$. Denote $K$ the fraction field of $A$.
What we know at this point is the following:
\begin{enumerate}
\item $A \subset B$ is a finitely generated extension of domains,
\item the element $g \otimes 1$ is invertible in $B \otimes_A K$,
\item $d = \dim(B \otimes_A K) = \dim(B \otimes_A \kappa(\mathfrak p))$,
\item $g \otimes 1$ is not a unit of $B \otimes_A \kappa(\mathfrak p)$, and
\item $g \otimes 1$ is not in any of the minimal primes of
$B \otimes_A \kappa(\mathfrak p)$.
\end{enumerate}
We are seeking a contradiction.

\medskip\noindent
Pick elements $x_1, \ldots, x_n \in B$ which generate $B$ over $A$.
For a finitely generated $\mathbf{Z}$-algebra $A_0 \subset A$
let $B_0 \subset B$ be the $A_0$-subalgebra generated by
$x_1, \ldots, x_n$, denote $K_0$ the fraction field of $A_0$, and set
$\mathfrak p_0 = A_0 \cap \mathfrak p$.
We claim that when $A_0$ is large enough then (1) -- (5) also hold for
the system $(A_0 \subset B_0, g, \mathfrak p_0)$.

\medskip\noindent
We prove each of the conditions in turn. Part (1) holds by construction.
For part (2) write $(g \otimes 1) h = 1$ for some
$h \otimes 1/a \in B \otimes_A K$. Write
$g = \sum a_I x^I$, $h = \sum a'_I x^I$ (multi-index notation)
for some coefficients $a_I, a'_I \in A$. As soon as $A_0$ contains
$a$ and the $a_I, a'_I$ then (2) holds because
$B_0 \otimes_{A_0} K_0 \subset B \otimes_A K$ (as localizations of the
injective map $B_0 \to B$).
To achieve (3) consider the exact sequence
$$
0 \to I \to A[X_1, \ldots, X_n] \to B \to 0
$$
which defines $I$ where the second map sends $X_i$ to $x_i$. Since $\otimes$
is right exact we see that $I \otimes_A K$, respectively
$I \otimes_A \kappa(\mathfrak p)$ is the kernel of the surjection
$K[X_1, \ldots, X_n] \to B \otimes_A K$, respectively
$\kappa(\mathfrak p)[X_1, \ldots, X_n] \to B \otimes_A \kappa(\mathfrak p)$.
As a polynomial ring over a field is Noetherian
there exist finitely many elements $h_j \in I$, $j = 1, \ldots, m$
which generate $I \otimes_A K$ and $I \otimes_A \kappa(\mathfrak p)$.
Write $h_j = \sum a_{j, I}X^I$. As soon as
$A_0$ contains all $a_{j, I}$ we get to the situation where
$$
B_0 \otimes_{A_0} K_0 \otimes_{K_0} K = B \otimes_A K
\quad\text{and}\quad
B_0 \otimes_{A_0} \kappa(\mathfrak p_0)
\otimes_{\kappa(\mathfrak p_0)} \kappa(\mathfrak p)
=
B \otimes_A \kappa(\mathfrak p).
$$
By either
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-after-base-change}
or
Algebra, Lemma \ref{algebra-lemma-dimension-preserved-field-extension}
we see that the dimension equalities of (3) are satisfied.
Part (4) is immediate. As
$B_0 \otimes_{A_0} \kappa(\mathfrak p_0) \subset
B \otimes_A \kappa(\mathfrak p)$ each minimal prime of
$B_0 \otimes_{A_0} \kappa(\mathfrak p_0)$ lies under a minimal
prime of $B \otimes_A \kappa(\mathfrak p)$ by
Algebra, Lemma \ref{algebra-lemma-image-dense-generic-points}.
This implies that (5) holds.
In this way we reduce the problem to the Noetherian case which we
have dealt with above.
\end{proof}

\noindent
Here is an algebraic application of the lemma above.
The fourth assumption of the lemma holds if $A \to B$ is flat, see
Lemma \ref{lemma-equality-dimensions}.

\begin{lemma}
\label{lemma-horizontal}
Let $A \to B$ be a local homomorphism of local rings, and
$g \in \mathfrak m_B$. Assume
\begin{enumerate}
\item $A$ and $B$ are domains and $A \subset B$,
\item $B$ is essentially of finite type over $A$,
\item $g$ is not contained in any minimal prime over $\mathfrak m_AB$, and
\item $\dim(B/\mathfrak m_AB) +
\text{trdeg}_{\kappa(\mathfrak m_A)}(\kappa(\mathfrak m_B)) =
\text{trdeg}_A(B)$.
\end{enumerate}
Then $A \subset B/gB$, i.e., the generic point of $\Spec(A)$
is in the image of the morphism $\Spec(B/gB) \to \Spec(A)$.
\end{lemma}

\begin{proof}
Note that the two assertions are equivalent by
Algebra, Lemma \ref{algebra-lemma-image-dense-generic-points}.
To start the proof let $C$ be an $A$-algebra of finite type
and $\mathfrak q$ a prime of $C$ such that $B = C_{\mathfrak q}$.
Of course we may assume that $C$ is a domain and that $g \in C$.
After replacing $C$ by a localization we see that
$\dim(C/\mathfrak m_AC) = \dim(B/\mathfrak m_AB) +
\text{trdeg}_{\kappa(\mathfrak m_A)}(\kappa(\mathfrak m_B))$, see
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point}.
Setting $K$ equal to the fraction field of $A$
we see by the same reference that
$\dim(C \otimes_A K) = \text{trdeg}_A(B)$. Hence assumption
(4) means that the generic and closed fibres of the morphism
$\Spec(C) \to \Spec(A)$ have the same dimension.

\medskip\noindent
Suppose that the lemma is false. Then $(B/gB) \otimes_A K = 0$.
This means that $g \otimes 1$ is invertible in $B \otimes_A K
= C_{\mathfrak q} \otimes_A K$. As $C_{\mathfrak q}$ is a limit
of principal localizations we conclude that $g \otimes 1$
is invertible in $C_h \otimes_A K$ for some
$h \in C$, $h \not \in \mathfrak q$. Thus after replacing $C$
by $C_h$ we may assume that $(C/gC) \otimes_A K = 0$.
We do one more replacement of $C$ to make sure that the minimal
primes of $C/\mathfrak m_AC$ correspond one-to-one with the minimal
primes of $B/\mathfrak m_AB$. At this point we apply
Lemma \ref{lemma-locally-principal-vertical}
to $X = \Spec(C) \to \Spec(A) = S$ and the locally closed
subscheme $Z = \Spec(C/gC)$. Since $Z_K = \emptyset$ we see that
$Z \otimes \kappa(\mathfrak m_A)$ has to contain an irreducible
component of
$X \otimes \kappa(\mathfrak m_A) = \Spec(C/\mathfrak m_AC)$.
But this contradicts the assumption that $g$ is not contained
in any prime minimal over $\mathfrak m_AB$. The lemma follows.
\end{proof}

\begin{lemma}
\label{lemma-equality-dimensions}
Let $A \to B$ be a local homomorphism of local rings. Assume
\begin{enumerate}
\item $A$ and $B$ are domains and $A \subset B$,
\item $B$ is essentially of finite type over $A$, and
\item $B$ is flat over $A$.
\end{enumerate}
Then we have
$$
\dim(B/\mathfrak m_AB) +
\text{trdeg}_{\kappa(\mathfrak m_A)}(\kappa(\mathfrak m_B)) =
\text{trdeg}_A(B).
$$
\end{lemma}

\begin{proof}
Let $C$ be an $A$-algebra of finite type and $\mathfrak q$ a prime of $C$
such that $B = C_{\mathfrak q}$. We may assume $C$ is a domain.
We have
$\dim_{\mathfrak q}(C/\mathfrak m_AC) = \dim(B/\mathfrak m_AB) +
\text{trdeg}_{\kappa(\mathfrak m_A)}(\kappa(\mathfrak m_B))$, see
Morphisms, Lemma \ref{morphisms-lemma-dimension-fibre-at-a-point}.
Setting $K$ equal to the fraction field of $A$
we see by the same reference that
$\dim(C \otimes_A K) = \text{trdeg}_A(B)$.
Thus we are really trying to prove that
$\dim_{\mathfrak q}(C/\mathfrak m_AC) = \dim(C \otimes_A K)$.
Choose a valuation ring $A'$ in $K$ dominating $A$, see
Algebra, Lemma \ref{algebra-lemma-dominate}.
Set $C' = C \otimes_A A'$.
Choose a prime $\mathfrak q'$ of $C'$ lying over $\mathfrak q$; such a
prime exists because
$$
C'/\mathfrak m_{A'}C' =
C/\mathfrak m_AC \otimes_{\kappa(\mathfrak m_A)} \kappa(\mathfrak m_{A'})
$$
which proves that $C/\mathfrak m_AC \to C'/\mathfrak m_{A'}C'$ is faithfully
flat. This also proves that
$\dim_{\mathfrak q}(C/\mathfrak m_AC) =
\dim_{\mathfrak q'}(C'/\mathfrak m_{A'}C')$, see
Algebra,
Lemma \ref{algebra-lemma-dimension-at-a-point-preserved-field-extension}.
Note that $B' = C'_{\mathfrak q'}$ is a localization of $B \otimes_A A'$.
Hence $B'$ is flat over $A'$. The generic fibre $B' \otimes_{A'} K$
is a localization of $B \otimes_A K$. Hence $B'$ is a domain.
If we prove the lemma for $A' \subset B'$, then we get the equality
$\dim_{\mathfrak q'}(C'/\mathfrak m_{A'}C') = \dim(C' \otimes_{A'} K)$
which implies the desired equality
$\dim_{\mathfrak q}(C/\mathfrak m_AC) = \dim(C \otimes_A K)$
by what was said above. This reduces the
lemma to the case where $A$ is a valuation ring.

\medskip\noindent
Let $A \subset B$ be as in the lemma with $A$ a valuation ring.
As before write $B = C_{\mathfrak q}$ for some domain $C$ of finite
type over $A$. By
Algebra,
Lemma \ref{algebra-lemma-finite-type-domain-over-valuation-ring-dim-fibres}
we obtain $\dim(C/\mathfrak m_AC) = \dim(C \otimes_A K)$ and we win.
\end{proof}

\begin{lemma}
\label{lemma-closed-point-nearby-fibre}
Let $f : X \to S$ be a morphism of schemes.
Let $x \leadsto x'$ be a specialization of points in $X$.
Set $s = f(x)$ and $s' = f(x')$.
Assume
\begin{enumerate}
\item $x'$ is a closed point of $X_{s'}$, and
\item $f$ is locally of finite type.
\end{enumerate}
Then the set
$$
\{x_1 \in X
\text{ such that }
f(x_1) = s
\text{ and }
x_1\text{ is closed in }X_s
\text{ and }
x \leadsto x_1 \leadsto x'
\}
$$
is dense in the closure of $x$ in $X_s$.
\end{lemma}

\begin{proof}
We apply
Schemes, Lemma \ref{schemes-lemma-points-specialize}
to the specialization $x \leadsto x'$.
This produces a morphism $\varphi : \Spec(B) \to X$
where $B$ is a valuation ring such that $\varphi$ maps the
generic point to $x$ and the closed point to $x'$. We may also
assume that $\kappa(x)$ is the fraction field of $B$.
Let $A = B \cap \kappa(s)$. Note that this is a valuation ring (see
Algebra, Lemma \ref{algebra-lemma-valuation-ring-cap-field})
which dominates the image of $\mathcal{O}_{S, s'} \to \kappa(s)$.
Consider the commutative diagram
$$
\xymatrix{
\Spec(B) \ar[rd] \ar[r] &
X_A \ar[d] \ar[r] & X \ar[d] \\
& \Spec(A) \ar[r] & S
}
$$
The generic (resp.\ closed) point of $B$ maps to a point $x_A$
(resp.\ $x'_A$) of $X_A$ lying over the generic (resp.\ closed)
point of $\Spec(A)$. Note that $x'_A$ is a closed point
of the special fibre of $X_A$ by
Morphisms,
Lemma \ref{morphisms-lemma-base-change-closed-point-fibre-locally-finite-type}.
Note that the generic fibre of $X_A \to \Spec(A)$ is isomorphic
to $X_s$. Thus we have reduced the lemma to the case where $S$ is
the spectrum of a valuation ring, $s = \eta \in S$ is the generic point, and
$s' \in S$ is the closed point.

\medskip\noindent
We will prove the lemma by induction on $\dim_x(X_\eta)$.
If $\dim_x(X_\eta) = 0$, then there are no other points of $X_\eta$
specializing to $x$ and $x$ is closed in its fibre, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize},
and the result holds. Assume $\dim_x(X_\eta) > 0$.

\medskip\noindent
Let $X' \subset X$ be the reduced induced scheme structure on
the irreducible closed subscheme $\overline{\{x\}}$ of $X$, see
Schemes, Definition \ref{schemes-definition-reduced-induced-scheme}.
To prove the lemma we may replace $X$ by $X'$ as this only decreases
$\dim_x(X_\eta)$. Hence we may also assume that $X$ is an integral scheme
and that $x$ is its generic point. In addition, we may replace $X$ by an
affine neighbourhood of $x'$. Thus we have $X = \Spec(B)$ where
$A \subset B$ is a finite type extension of domains. Note that in
this case $\dim_x(X_\eta) = \dim(X_\eta) = \dim(X_{s'})$, and that in fact
$X_{s'}$ is equidimensional, see
Algebra,
Lemma \ref{algebra-lemma-finite-type-domain-over-valuation-ring-dim-fibres}.

\medskip\noindent
Let $W \subset X_\eta$ be a proper closed subset (this is the
subset we want to ``avoid''). As $X_s$ is of finite type over a field
we see that $W$ has finitely many irreducible components
$W = W_1 \cup \ldots \cup W_n$. Let
$\mathfrak q_j \subset B$, $j = 1, \ldots, r$
be the corresponding prime ideals. Let $\mathfrak q \subset B$
be the maximal ideal corresponding to the point $x'$.
Let $\mathfrak p_1, \ldots, \mathfrak p_s \subset B$ be the
minimal primes lying over $\mathfrak m_AB$. There are finitely
many as these correspond to the irreducible components of the
Noetherian scheme $X_{s'}$. Moreover, each of these irreducible
components has dimension $> 0$ (see above) hence we see that
$\mathfrak p_i \not = \mathfrak q$ for all $i$.
Now, pick an element $g \in \mathfrak q$ such that
$g \not \in \mathfrak q_j$ for all $j$ and $g \not \in \mathfrak p_i$
for all $i$, see
Algebra, Lemma \ref{algebra-lemma-silly}.
Denote $Z \subset X$ the locally principal closed subscheme defined by $g$.
Let $Z_\eta = Z_{1, \eta} \cup \ldots \cup Z_{n, \eta}$, $n \geq 0$
be the decomposition of the generic fibre of $Z$ into irreducible
components (finitely many as the generic fibre is Noetherian).
Denote $Z_i \subset X$ the closure of $Z_{i, \eta}$.
After replacing $X$ by a smaller affine neighbourhood
we may assume that $x' \in Z_i$ for each $i = 1, \ldots, n$.
By construction $Z \cap X_{s'}$ does not contain any irreducible
component of $X_{s'}$. Hence by
Lemma \ref{lemma-locally-principal-vertical}
we conclude that $Z_\eta \not = \emptyset$! In other words
$n \geq 1$. Letting $x_1 \in Z_1$ be the generic point we see
that $x_1 \leadsto x'$ and $f(x_1) = \eta$.
Also, by construction $Z_{1, \eta} \cap W_j \subset W_j$
is a proper closed subset. Hence every irreducible component of
$Z_{1, \eta} \cap W_j$ has codimension $\geq 2$ in $X_\eta$
whereas $\text{codim}(Z_{1, \eta}, X_\eta) = 1$ by
Algebra, Lemma \ref{algebra-lemma-minimal-over-1}.
Thus $W \cap Z_{1, \eta}$ is a proper closed subset.
At this point we see that the induction hypothesis applies to
$Z_1 \to S$ and the specialization $x_1 \leadsto x'$.
This produces a closed point $x_2$ of $Z_{1, \eta}$ not contained
in $W$ which specializes to $x'$. Thus we obtain
$x \leadsto x_2 \leadsto x'$, the point $x_2$ is closed in $X_\eta$,
and $x_2 \not \in W$ as desired.
\end{proof}

\begin{remark}
\label{remark-full-specialization-sequence}
The proof of
Lemma \ref{lemma-closed-point-nearby-fibre}
actually shows that there exists a sequence of specializations
$$
x \leadsto x_1 \leadsto x_2 \leadsto \ldots \leadsto x_d \leadsto x'
$$
where all $x_i$ are in the fibre $X_s$, each specialization is
immediate, and $x_d$ is a closed point of $X_s$. The integer
$d = \text{trdeg}_{\kappa(s)}(\kappa(x)) = \dim(\overline{\{x\}})$
where the closure is taken in $X_s$. Moreover, the points
$x_i$ can be chosen to avoid any closed subset of $X_s$ which
does not contain the point $x$.
\end{remark}

\noindent
Examples, Section \ref{examples-section-topology-finite-type}
shows that the following lemma is false if $A$ is not assumed
Noetherian.

\begin{lemma}
\label{lemma-quasi-finite-quasi-section-meeting-nearby-open}
Let $\varphi : A \to B$ be a local ring map of local rings.
Let $V \subset \Spec(B)$ be an open subscheme
which contains at least one prime not lying over $\mathfrak m_A$.
Assume $A$ is Noetherian, $\varphi$ essentially of finite type, and
$A/\mathfrak m_A \subset B/\mathfrak m_B$ is finite.
Then there exists a $\mathfrak q \in V$,
$\mathfrak m_A \not = \mathfrak q \cap A$ such that
$A \to B/\mathfrak q$ is the localization of a quasi-finite ring map.
\end{lemma}

\begin{proof}
Since $A$ is Noetherian and $A \to B$ is essentially of finite type,
we know that $B$ is Noetherian too. By
Properties, Lemma \ref{properties-lemma-complement-closed-point-Jacobson}
the topological space $\Spec(B) \setminus \{\mathfrak m_B\}$
is Jacobson. Hence we can choose a closed point $\mathfrak q$
which is contained in the nonempty open
$$
V \setminus \{\mathfrak q \subset B \mid \mathfrak m_A = \mathfrak q \cap A\}.
$$
(Nonempty by assumption, open because $\{\mathfrak m_A\}$ is a closed
subset of $\Spec(A)$.)
Then $\Spec(B/\mathfrak q)$ has two points, namely $\mathfrak m_B$
and $\mathfrak q$ and $\mathfrak q$ does not lie over $\mathfrak m_A$.
Write $B/\mathfrak q = C_{\mathfrak m}$ for some finite type $A$-algebra
$C$ and prime ideal $\mathfrak m$. Then $A \to C$ is quasi-finite at
$\mathfrak m$ by
Algebra, Lemma \ref{algebra-lemma-isolated-point-fibre} (2).
Hence by
Algebra, Lemma \ref{algebra-lemma-quasi-finite-open}
we see that after replacing $C$ by a principal localization the ring
map $A \to C$ is quasi-finite.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-quasi-section-meeting-nearby-open-X}
Let $f : X \to S$ be a morphism of schemes.
Let $x \in X$ with image $s \in S$.
Let $U \subset X$ be an open subscheme.
Assume $f$ locally of finite type, $S$ locally Noetherian, $x$ a closed
point of $X_s$, and assume there exists a point $x' \in U$ with
$x' \leadsto x$ and $f(x') \not = s$. Then there exists a closed
subscheme $Z \subset X$ such that (a) $x \in Z$, (b) $f|_Z : Z \to S$ is
quasi-finite at $x$, and (c) there exists a $z \in Z$, $z \in U$,
$z \leadsto x$ and $f(z) \not = s$.
\end{lemma}

\begin{proof}
This is a reformulation of
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open}.
Namely, set $A = \mathcal{O}_{S, s}$ and $B = \mathcal{O}_{X, x}$.
Denote $V \subset \Spec(B)$ the inverse image of $U$.
The ring map $f^\sharp : A \to B$ is essentially of finite type.
By assumption there exists at least one point of $V$ which does not
map to the closed point of $\Spec(A)$. Hence all the assumptions of
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open}
hold and we obtain a prime $\mathfrak q \subset B$ which does not
lie over $\mathfrak m_A$ and such that $A \to B/\mathfrak q$ is
the localization of a quasi-finite ring map. Let $z \in X$ be the
image of the point $\mathfrak q$ under the canonical
morphism $\Spec(B) \to X$. Set $Z = \overline{\{z\}}$
with the induced reduced scheme structure. As $z \leadsto x$
we see that $x \in Z$ and $\mathcal{O}_{Z, x} = B/\mathfrak q$.
By construction $Z \to S$ is quasi-finite at $x$.
\end{proof}

\begin{remark}
\label{remark-alternative-closed-point-nearby-fibre}
We can use
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open}
or its variant
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open-X}
to give an alternative proof of
Lemma \ref{lemma-closed-point-nearby-fibre}
in case $S$ is locally Noetherian.
Here is a rough sketch.
Namely, first replace $S$ by
the spectrum of the local ring at $s'$. Then we may use induction
on $\dim(S)$. The case $\dim(S) = 0$ is trivial because then $s' = s$.
Replace $X$ by the reduced induced scheme structure on $\overline{\{x\}}$.
Apply
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open-X}
to $X \to S$ and $x' \mapsto s'$ and any nonempty
open $U \subset X$ containing $x$. This gives us a closed subscheme
$x' \in Z \subset X$ a point $z \in Z$
such that $Z \to S$ is quasi-finite at $x'$ and such that $f(z) \not = s'$.
Then $z$ is a closed point of $X_{f(z)}$, and $z \leadsto x'$.
As $f(z) \not = s'$ we see $\dim(\mathcal{O}_{S, f(z)}) < \dim(S)$.
Since $x$ is the generic point of $X$ we see $x \leadsto z$, hence
$s = f(x) \leadsto f(z)$.
Apply the induction hypothesis to $s \leadsto f(z)$ and $z \mapsto f(z)$
to win.
\end{remark}

\begin{lemma}
\label{lemma-change-hypotheses}
Suppose that $f : X \to S$ is locally of finite type, $S$ locally Noetherian,
$x \in X$ a closed point of its fibre $X_s$, and $U \subset X$ an open
subscheme such that $U \cap X_s = \emptyset$ and $x \in \overline{U}$, then
the conclusions of
Lemma \ref{lemma-quasi-finite-quasi-section-meeting-nearby-open-X}
hold.
\end{lemma}

\begin{proof}
Namely, we can reduce this to the cited lemma as follows: First we
replace $X$ and $S$ by affine neighbourhoods of $x$ and $s$. Then $X$ is
Noetherian, in particular $U$ is quasi-compact (see
Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}
and
Topology, Lemmas \ref{topology-lemma-Noetherian} and
\ref{topology-lemma-Noetherian-quasi-compact}).
Hence there exists a specialization $x' \leadsto x$ with $x' \in U$ (see
Morphisms, Lemma \ref{morphisms-lemma-reach-points-scheme-theoretic-image}).
Note that $f(x') \not = s$. Thus we see all hypotheses of the lemma
are satisfied and we win.
\end{proof}



\section{Stein factorization}
\label{section-stein-factorization}

\noindent
Stein factorization is the statement that a proper morphism $f : X \to S$
with $f_*\mathcal{O}_X = \mathcal{O}_S$ has connected fibres.

\begin{lemma}
\label{lemma-stein-universally-closed}
Let $S$ be a scheme. Let $f : X \to S$ be a universally closed and
quasi-separated morphism. There exists a factorization
$$
\xymatrix{
X \ar[rr]_{f'} \ar[rd]_f & & S' \ar[dl]^\pi \\
& S &
}
$$
with the following properties:
\begin{enumerate}
\item the morphism $f'$ is universally closed, quasi-compact, quasi-separated,
and surjective,
\item the morphism $\pi : S' \to S$ is integral,
\item we have $f'_*\mathcal{O}_X = \mathcal{O}_{S'}$,
\item we have $S' = \underline{\Spec}_S(f_*\mathcal{O}_X)$, and
\item $S'$ is the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
\end{enumerate}
Formation of the factorization $f = \pi \circ f'$ commutes
with flat base change.
\end{lemma}

\begin{proof}
By Morphisms, Lemma \ref{morphisms-lemma-universally-closed-quasi-compact}
the morphism $f$ is quasi-compact. Hence the normalization $S'$ of $S$ in
$X$ is defined (Morphisms, Definition
\ref{morphisms-definition-normalization-X-in-Y})
and we have the factorization $X \to S' \to S$. By
Morphisms, Lemma \ref{morphisms-lemma-normalization-in-universally-closed}
we have (2), (4), and (5). The morphism $f'$ is universally closed by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}.
It is quasi-compact by
Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}
and quasi-separated by
Schemes, Lemma \ref{schemes-lemma-compose-after-separated}.

\medskip\noindent
To show the remaining statements we may assume the base scheme $S$ is affine,
say $S = \Spec(R)$. Then $S' = \Spec(A)$ with
$A = \Gamma(X, \mathcal{O}_X)$ an integral $R$-algebra.
Thus it is clear that $f'_*\mathcal{O}_X$
is $\mathcal{O}_{S'}$ (because $f'_*\mathcal{O}_X$ is quasi-coherent,
by
Schemes, Lemma
\ref{schemes-lemma-push-forward-quasi-coherent},
and hence equal to $\widetilde{A}$). This proves (3).

\medskip\noindent
Let us show that $f'$ is surjective. As $f'$ is universally closed (see above)
the image of $f'$ is a closed subset
$V(I) \subset S' = \Spec(A)$. Pick $h \in I$. Then
$h|_X = f^\sharp(h)$ is a global section of the structure sheaf of
$X$ which vanishes at every point. As $X$ is quasi-compact this means
that $h|_X$ is a nilpotent section, i.e., $h^n|X = 0$ for some $n > 0$.
But $A = \Gamma(X, \mathcal{O}_X)$, hence $h^n = 0$.
In other words $I$ is contained in the Jacobson radical ideal of $A$
and we conclude that $V(I) = S'$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-stein-universally-closed-residue-fields}
In Lemma \ref{lemma-stein-universally-closed} assume in addition that
$f$ is locally of finite type. Then for $s \in S$ the fibre
$\pi^{-1}(\{s\}) = \{s_1, \ldots, s_n\}$ is finite and the field extensions
$\kappa(s_i)/\kappa(s)$ are finite.
\end{lemma}

\begin{proof}
Recall that there are no specializations among the points of $\pi^{-1}(\{s\})$,
see Algebra, Lemma \ref{algebra-lemma-integral-no-inclusion}.
As $f'$ is surjective, we find that $|X_s| \to \pi^{-1}(\{s\})$ is surjective.
Observe that $X_s$ is a quasi-separated scheme of finite type
over a field (quasi-compactness was shown in the proof of the
referenced lemma). Thus $X_s$ is Noetherian
(Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}).
A topological argument (omitted) now shows that $\pi^{-1}(\{s\})$ is finite.
For each $i$ we can pick a finite type point $x_i \in X_s$ mapping to $s_i$
(Morphisms, Lemma \ref{morphisms-lemma-enough-finite-type-points}).
We conclude that $\kappa(s_i)/\kappa(s)$ is finite:
$x_i$ can be represented by a morphism $\Spec(k_i) \to X_s$
of finite type (by our definition of finite type points)
and hence $\Spec(k_i) \to s = \Spec(\kappa(s))$ is of finite type
(as a composition of finite type morphisms),
hence $k_i/\kappa(s)$ is finite (Morphisms, Lemma
\ref{morphisms-lemma-point-finite-type}).
\end{proof}

\begin{lemma}
\label{lemma-characterize-geometrically-connected-fibres}
Let $f : X \to S$ be a morphism of schemes.
Let $s \in S$. Then $X_s$ is geometrically connected, if and
only if for every \'etale neighbourhood $(U, u) \to (S, s)$
the base change $X_U \to U$ has connected fibre $X_u$.
\end{lemma}

\begin{proof}
If $X_s$ is geometrically connected, then any base change of it is connected.
On the other hand, suppose that $X_s$ is not geometrically connected.
Then by
Varieties, Lemma
\ref{varieties-lemma-characterize-geometrically-disconnected}
we see that $X_s \times_{\Spec(\kappa(s))} \Spec(k)$ is
disconnected for some
finite separable field extension $k/\kappa(s)$. By
Lemma \ref{lemma-realize-prescribed-residue-field-extension-etale}
there exists an affine \'etale neighbourhood $(U, u) \to (S, s)$ such that
$\kappa(u)/\kappa(s)$ is identified with $k/\kappa(s)$.
In this case $X_u$ is disconnected.
\end{proof}

\begin{theorem}[Stein factorization; Noetherian case]
\label{theorem-stein-factorization-Noetherian}
Let $S$ be a locally Noetherian scheme.
Let $f : X \to S$ be a proper morphism.
There exists a factorization
$$
\xymatrix{
X \ar[rr]_{f'} \ar[rd]_f & & S' \ar[dl]^\pi \\
& S &
}
$$
with the following properties:
\begin{enumerate}
\item the morphism $f'$ is proper with geometrically connected fibres,
\item the morphism $\pi : S' \to S$ is finite,
\item we have $f'_*\mathcal{O}_X = \mathcal{O}_{S'}$,
\item we have $S' = \underline{\Spec}_S(f_*\mathcal{O}_X)$, and
\item $S'$ is the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
\end{enumerate}
\end{theorem}

\begin{proof}
Let $f = \pi \circ f'$ be the factorization of
Lemma \ref{lemma-stein-universally-closed}. Note that besides the
conclusions of Lemma \ref{lemma-stein-universally-closed} we
also have that $f'$ is separated
(Schemes, Lemma \ref{schemes-lemma-compose-after-separated})
and finite type
(Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}).
Hence $f'$ is proper. By
Cohomology of Schemes, Proposition
\ref{coherent-proposition-proper-pushforward-coherent}
we see that $f_*\mathcal{O}_X$ is a coherent $\mathcal{O}_S$-module.
Hence we see that $\pi$ is finite, i.e., (2) holds.

\medskip\noindent
This proves all but the most interesting assertion, namely that
all the fibres of $f'$ are geometrically connected.
It is clear from the discussion above that we may replace $S$ by $S'$,
and we may therefore assume that $S$ is Noetherian, affine,
$f : X \to S$ is proper, and $f_*\mathcal{O}_X = \mathcal{O}_S$.
Let $s \in S$ be a point of $S$. We have to show that $X_s$ is
geometrically connected. By Lemma
\ref{lemma-characterize-geometrically-connected-fibres}
we see that it suffices to show $X_u$ is connected
for every \'etale neighbourhood $(U, u) \to (S, s)$.
We may assume $U$ is affine. Thus $U$ is Noetherian
(Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}),
the base change $f_U : X_U \to U$ is proper
(Morphisms, Lemma \ref{morphisms-lemma-base-change-proper}),
and that also $(f_U)_*\mathcal{O}_{X_U} = \mathcal{O}_U$
(Cohomology of Schemes, Lemma \ref{coherent-lemma-flat-base-change-cohomology}).
Hence after replacing
$(f : X \to S, s)$ by the base change $(f_U : X_U \to U, u)$
it suffices to prove that the fibre $X_s$ is connected when
$f_*\mathcal{O}_X = \mathcal{O}_S$. We can deduce this
from Derived Categories of Schemes, Lemma
\ref{perfect-lemma-proper-idempotent-on-fibre}
(by looking at idempotents in the structure sheaf of $X_s$)
but we will also give a direct argument below.

\medskip\noindent
Namely, we apply the theorem on formal functions,
more precisely Cohomology of Schemes, Lemma
\ref{coherent-lemma-formal-functions-stalk}.
It tells us that
$$
\mathcal{O}^\wedge_{S, s} = (f_*\mathcal{O}_X)_s^\wedge =
\lim_n H^0(X_n, \mathcal{O}_{X_n})
$$
where $X_n$ is the $n$th infinitesimal neighbourhood of $X_s$.
Since the underlying topological space of $X_n$ is equal to that
of $X_s$ we see that if $X_s = T_1 \amalg T_2$ is a disjoint union
of nonempty open and closed subschemes, then similarly
$X_n = T_{1, n} \amalg T_{2, n}$ for all $n$. And this in turn means
$H^0(X_n, \mathcal{O}_{X_n})$ contains a nontrivial idempotent $e_{1, n}$,
namely the function which is identically $1$ on $T_{1, n}$ and
identically $0$ on $T_{2, n}$. It is clear that $e_{1, n + 1}$
restricts to $e_{1, n}$ on $X_n$. Hence $e_1 = \lim e_{1, n}$
is a nontrivial idempotent of the limit. This contradicts the fact
that $\mathcal{O}^\wedge_{S, s}$ is a local ring. Thus the
assumption was wrong, i.e., $X_s$ is connected, and we win.
\end{proof}

\begin{theorem}[Stein factorization; general case]
\label{theorem-stein-factorization-general}
Let $S$ be a scheme.
Let $f : X \to S$ be a proper morphism.
There exists a factorization
$$
\xymatrix{
X \ar[rr]_{f'} \ar[rd]_f & & S' \ar[dl]^\pi \\
& S &
}
$$
with the following properties:
\begin{enumerate}
\item the morphism $f'$ is proper with geometrically connected fibres,
\item the morphism $\pi : S' \to S$ is integral,
\item we have $f'_*\mathcal{O}_X = \mathcal{O}_{S'}$,
\item we have $S' = \underline{\Spec}_S(f_*\mathcal{O}_X)$, and
\item $S'$ is the normalization of $S$ in $X$, see
Morphisms, Definition \ref{morphisms-definition-normalization-X-in-Y}.
\end{enumerate}
\end{theorem}

\begin{proof}
We may apply Lemma \ref{lemma-stein-universally-closed} to get the
morphism $f' : X \to S'$.
Note that besides the
conclusions of Lemma \ref{lemma-stein-universally-closed} we
also have that $f'$ is separated
(Schemes, Lemma \ref{schemes-lemma-compose-after-separated})
and finite type
(Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}).
Hence $f'$ is proper. At this point we have proved all of the
statements except for the statement
that $f'$ has geometrically connected fibres.

\medskip\noindent
We may assume that $S = \Spec(R)$ is affine.
Set $R' = \Gamma(X, \mathcal{O}_X)$. Then $S' = \Spec(R')$.
Thus we may replace $S$ by $S'$ and assume that
$S = \Spec(R)$ is affine $R = \Gamma(X, \mathcal{O}_X)$.
Next, let $s \in S$ be a point. Let $U \to S$ be an \'etale morphism
of affine schemes and let $u \in U$ be a point mapping to $s$.
Let $X_U \to U$ be the base change of $X$. By
Lemma \ref{lemma-characterize-geometrically-connected-fibres}
it suffices to show that the fibre of $X_U \to U$ over $u$ is
connected. By
Cohomology of Schemes, Lemma \ref{coherent-lemma-flat-base-change-cohomology}
we see that
$\Gamma(X_U, \mathcal{O}_{X_U}) = \Gamma(U, \mathcal{O}_U)$.
Hence we have to show: Given
$S = \Spec(R)$ affine, $X \to S$ proper with $\Gamma(X, \mathcal{O}_X) = R$
and $s \in S$ is a point, the fibre $X_s$ is connected.

\medskip\noindent
To do this it suffices to show that the only idempotents
$e \in H^0(X_s, \mathcal{O}_{X_s})$ are $0$ and $1$ (we already
know that $X_s$ is nonempty by Lemma \ref{lemma-stein-universally-closed}).
By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-proper-idempotent-on-fibre}
after replacing $R$ by a principal localization
we may assume $e$ is the image of an element of $R$.
Since $R \to H^0(X_s, \mathcal{O}_{X_s})$ factors through
$\kappa(s)$ we conclude.
\end{proof}

\noindent
Here is an application.

\begin{lemma}
\label{lemma-geometrically-connected-fibres-towards-normal}
Let $f : X \to S$ be a morphism of schemes. Assume
\begin{enumerate}
\item $f$ is proper,
\item $S$ is integral with generic point $\xi$,
\item $S$ is normal,
\item $X$ is reduced,
\item every generic point of an irreducible component of $X$ maps to $\xi$,
\item we have $H^0(X_\xi, \mathcal{O}) = \kappa(\xi)$.
\end{enumerate}
Then $f_*\mathcal{O}_X = \mathcal{O}_S$ and $f$
has geometrically connected fibres.
\end{lemma}

\begin{proof}
Apply Theorem \ref{theorem-stein-factorization-general} to get a
factorization $X \to S' \to S$. It is enough to show that $S' = S$.
This will follow from Morphisms, Lemma
\ref{morphisms-lemma-finite-birational-over-normal}.
Namely, $S'$ is reduced because $X$ is reduced
(Morphisms, Lemma \ref{morphisms-lemma-normalization-in-reduced}).
The morphism $S' \to S$ is integral by the theorem cited above.
Every generic point of $S'$ lies over $\xi$ by
Morphisms, Lemma \ref{morphisms-lemma-normalization-generic}
and assumption (5). On the other hand, since $S'$ is the relative
spectrum of $f_*\mathcal{O}_X$ we see that the scheme theoretic fibre
$S'_\xi$ is the spectrum of $H^0(X_\xi, \mathcal{O})$ which is
equal to $\kappa(\xi)$ by assumption. Hence $S'$ is an integral
scheme with function field equal to the function field of $S$.
This finishes the proof.
\end{proof}

\noindent
Here is another application.

\begin{lemma}
\label{lemma-proper-flat-nr-geom-conn-comps-lower-semicontinuous}
Let $X \to S$ be a flat proper morphism of finite presentation. Let
$n_{X/S}$ be the function on $S$ counting the numbers of geometric
connected components of fibres of $f$ introduced in
Lemma \ref{lemma-base-change-fibres-nr-geometrically-connected-components}.
Then $n_{X/S}$ is lower semi-continuous.
\end{lemma}

\begin{proof}
Let $s \in S$. Set $n = n_{X/S}(s)$. Note that $n < \infty$ as the geometric
fibre of $X \to S$ at $s$ is a proper scheme over a field, hence Noetherian,
hence has a finite number of connected components. We have to find an open
neighbourhood $V$ of $s$ such that $n_{X/S}|_V \geq n$.
Let $X \to S' \to S$ be the Stein factorization as in
Theorem \ref{theorem-stein-factorization-general}.
By Lemma \ref{lemma-stein-universally-closed-residue-fields}
there are finitely many points $s'_1, \ldots, s'_m \in S'$ lying over $s$
and the extensions $\kappa(s'_i)/\kappa(s)$ are finite.
Then Lemma \ref{lemma-etale-makes-integral-split}
tells us that after replacing $S$ by an \'etale neighbourhood
of $s$ we may assume $S' = V_1 \amalg \ldots \amalg V_m$ as a scheme
with $s'_i \in V_i$ and $\kappa(s'_i)/\kappa(s)$ purely inseparable.
Then the schemes $X_{s_i'}$ are geometrically connected over
$\kappa(s)$, hence $m = n$. The schemes
$X_i = (f')^{-1}(V_i)$, $i = 1, \ldots, n$
are flat and of finite presentation over $S$. Hence the image of $X_i \to S$
is open (Morphisms, Lemma \ref{morphisms-lemma-fppf-open}).
Thus in a neighbourhood of $s$ we see that $n_{X/S}$ is
at least $n$.
\end{proof}

\begin{lemma}
\label{lemma-proper-flat-geom-red}
Let $f : X \to S$ be a morphism of schemes. Assume
\begin{enumerate}
\item $f$ is proper, flat, and of finite presentation, and
\item the geometric fibres of $f$ are reduced.
\end{enumerate}
Then the function $n_{X/S} : S \to \mathbf{Z}$
counting the numbers of geometric connected components
of fibres of $f$ is locally constant.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-proper-flat-nr-geom-conn-comps-lower-semicontinuous}
the function $n_{X/S}$ is lower semincontinuous.
For $s \in S$ consider the $\kappa(s)$-algebra
$$
A = H^0(X_s, \mathcal{O}_{X_s})
$$
By Varieties, Lemma
\ref{varieties-lemma-proper-geometrically-reduced-global-sections}
and the fact that $X_s$ is geometrically reduced
$A$ is finite product of finite separable extensions of $\kappa(s)$.
Hence $A \otimes_{\kappa(s)} \kappa(\overline{s})$ is a product
of $\beta_0(s) = \dim_{\kappa(s)} H^0(E \otimes^\mathbf{L} \kappa(s))$
copies of $\kappa(\overline{s})$. Thus
$X_{\overline{s}}$ has $\beta_0(s) = \dim_{\kappa(s)} A$
connected components. In other words, we have $n_{X/S} = \beta_0$
as functions on $S$. Thus $n_{X/S}$ is upper semi-continuous by
Derived Categories of Schemes, Lemma \ref{perfect-lemma-jump-loci-geometric}.
This finishes the proof.
\end{proof}

\noindent
A final application.

\begin{lemma}
\label{lemma-split-off-proper-part-henselian}
\begin{reference}
A reference for the case of an adic Noetherian base is
\cite[III, Proposition 5.5.1]{EGA}
\end{reference}
Let $(A, I)$ be a henselian pair. Let $X \to \Spec(A)$
be separated and of finite type. Set $X_0 = X \times_{\Spec(A)} \Spec(A/I)$.
Let $Y \subset X_0$ be an open and closed subscheme such that
$Y \to \Spec(A/I)$ is proper. Then there exists an open and closed
subscheme $W \subset X$ which is proper over $A$ with
$W \times_{\Spec(A)} \Spec(A/I) = Y$.
\end{lemma}

\begin{proof}
We will denote $T \mapsto T_0$ the base change by $\Spec(A/I) \to \Spec(A)$.
By Chow's lemma (in the form of
Limits, Lemma \ref{limits-lemma-chow-finite-type})
there exists a surjective proper morphism $\varphi : X' \to X$ such
that $X'$ admits an immersion into $\mathbf{P}^n_A$.
Set $Y' = \varphi^{-1}(Y)$. This is an open and closed subscheme
of $X'_0$. Suppose the lemma holds for $(X', Y')$. Let $W' \subset X'$
be the open and closed subscheme proper over $A$ such that $Y' = W'_0$.
By Morphisms, Lemma \ref{morphisms-lemma-image-proper-scheme-closed}
$W = \varphi(W') \subset X$ and
$Q = \varphi(X' \setminus W') \subset X$ are closed subsets and by
Morphisms, Lemma \ref{morphisms-lemma-image-proper-is-proper}
$W$ is proper over $A$. The image of $W \cap Q$ in $\Spec(A)$ is closed.
Since $(A, I)$ is henselian, if $W \cap Q$ is nonempty, then we
find that $W \cap Q$ has a point lying over $\Spec(A/I)$.
This is impossible as $W'_0 = Y' = \varphi^{-1}(Y)$.
We conclude that $W$ is an open and closed subscheme
of $X$ proper over $A$ with $W_0 = Y$.
Thus we reduce to the case described in the next paragraph.

\medskip\noindent
Assume there exists an immersion $j : X \to \mathbf{P}^n_A$ over $A$.
Let $\overline{X}$ be the scheme theoretic image of $j$.
Since $j$ is a quasi-compact morphism
(Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence})
we see that $j : X \to \overline{X}$ is an open immersion
(Morphisms, Lemma \ref{morphisms-lemma-quasi-compact-immersion}).
Hence the base change $j_0 : X_0 \to \overline{X}_0$
is an open immersion as well.
Thus $j_0(Y) \subset \overline{X}_0$ is open.
It is also closed by Morphisms, Lemma
\ref{morphisms-lemma-image-proper-scheme-closed}.
Suppose that the lemma holds for $(\overline{X}, j_0(Y))$.
Let $\overline{W} \subset \overline{X}$ be the
corresponding open and closed subscheme proper over $A$
such that $j_0(Y) = \overline{W}_0$.
Then $T = \overline{W} \setminus j(X)$ is closed in $\overline{W}$,
hence has closed image in $\Spec(A)$ by properness of $\overline{W}$
over $A$. Since $(A, I)$ is henselian, we find that if $T$
is nonempty, then there is a point of $T$ mapping into $\Spec(A/I)$.
This is impossible because $j_0(Y) = \overline{W}_0$ is contained in $j(X)$.
Hence $\overline{W}$ is contained in $j(X)$ and we can
set $W \subset X$ equal to the unique open and closed
subscheme mapping isomorphically to $\overline{W}$ via $j$.
Thus we reduce to the case described in the next paragraph.

\medskip\noindent
Assume $X \subset \mathbf{P}^n_A$ is a closed subscheme.
Then $X \to \Spec(A)$ is a proper morphism.
Let $Z = X_0 \setminus Y$. This is an open and closed
subscheme of $X_0$ and $X_0 = Y \amalg Z$.
Let $X \to X' \to \Spec(A)$ be the Stein factorization as in
Theorem \ref{theorem-stein-factorization-general}.
Let $Y' \subset X'_0$ and $Z' \subset X'_0$ be the images of
$Y$ and $Z$.
Since the fibres of $X \to Z$ are geometrically connected,
we see that $Y' \cap Z' = \emptyset$.
Hence $X'_0 = Y' \amalg Z'$ as $X \to X'$ is surjective.
Since $X' \to \Spec(A)$ is integral, we see that
$X'$ is the spectrum of an $A$-algebra integral over $A$.
Recall that open and closed subsets of spectra correspond
$1$-to-$1$ with idempotents in the corresponding ring, see
Algebra, Lemma \ref{algebra-lemma-disjoint-decomposition}.
Hence by
More on Algebra, Lemma \ref{more-algebra-lemma-characterize-henselian-pair}
we see that we may write $X' = W' \amalg V'$
with $W'$ and $V'$ open and closed and
with $Y' = W'_0$ and $Z' = V'_0$.
Let $W$ be the inverse image in $X$
to finish the proof.
\end{proof}








\section{Improving morphisms of relative dimension one}
\label{section-make-good-curves}

\noindent
We can make any curve be smooth and projective after extending the
ground field, compactifying, and normalizing. This also implies
results about finite type morphisms whose generic fibres have dimension $1$.

\begin{lemma}
\label{lemma-make-good-curves}
Let $f : X \to S$ be a morphism of schemes. Let $\eta \in S$ be a
generic point of an irreducible component of $S$. Assume $f$ is
separated, of finite presentation, and $\dim(X_\eta) \leq 1$.
Then there exists a commutative diagram
$$
\xymatrix{
\overline{Y}_1 \amalg \ldots \amalg \overline{Y}_n \ar[rd] &
Y_1 \amalg \ldots \amalg Y_n \ar[r]_-\nu \ar[d] \ar[l]^j &
X_V \ar[r] \ar[d] &
X_U \ar[r] \ar[d] &
X \ar[d]^f \\
& T_1 \amalg \ldots \amalg T_n \ar[r] &
V \ar[r] &
U \ar[r] &
S
}
$$
of schemes with the following properties:
\begin{enumerate}
\item $U \subset X$ is an open neighbourhood of $\eta$,
\item $V \to U$ is a finite, surjective, universally injective morphism,
\item $X_U = U \times_S X$ and $X_V = V \times_S X$ are the base changes,
\item $\nu$ is finite, surjective, and there is an open $W \subset X_V$
such that
\begin{enumerate}
\item $W$ is dense in all fibres of $X_V \to V$,
\item $\nu^{-1}(W) \cap Y_i$ is dense in all fibres of $Y_i \to T_i$, and
\item $\nu^{-1}(W) \to W$ is a thickening,
\end{enumerate}
\item $j$ is an open immersion,
\item $T_i \to V$ is finite \'etale,
\item $Y_i \to T_i$ is surjective and smooth,
\item $\overline{Y}_i \to T_i$ is smooth, proper, with geometrically
connected fibres of dimension $\leq 1$.
\end{enumerate}
\end{lemma}

\begin{proof}
It is clear that we may replace $S$ by an open neighbourhood of $\eta$
and $X$ by the restriction to this open.
Moreover, we may replace $S$ by its reduction and $X$ by
the base change to this reduction.
Thus we may assume $S = \Spec(A)$ where $A$ is a reduced ring
and $\eta$ corresponds to a minimal prime ideal $\mathfrak p$.
Recall that the local ring $\mathcal{O}_{S, \eta} = A_\mathfrak p$
is equal to $\kappa(\mathfrak p)$ in this case, see
Algebra, Lemma \ref{algebra-lemma-minimal-prime-reduced-ring}.

\medskip\noindent
Apply Varieties, Lemma
\ref{varieties-lemma-dim-1-projective-completion-after-insep}
to the scheme $X_\eta$ over $k = \kappa(\eta)$.
Denote $k'/k$ the purely inseparable field extension this produces.
In the next paragraph we reduce to the case $k' = k$.
(This step corresponds to finding the morphism $V \to U$ in
the statement of the lemma; in particular we can take $V = U$
if the characteristic of $\kappa(\mathfrak p)$ is zero.)

\medskip\noindent
If the characteristic of $k = \kappa(\mathfrak p)$ is zero, then
$k' = k$. If the characteristic of $k = \kappa(\mathfrak p)$
is $p > 0$, then $p$ maps to zero in $A_\mathfrak p = \kappa(\mathfrak p)$.
Hence after replacing $A$ by a principal localization (i.e.,
shrinking $S$) we may assume $p = 0$ in $A$. If $k' \not = k$, then
there exists an $\beta \in k'$, $\beta \not \in k$
such that $\beta^p \in k$. After replacing $A$ by a principal
localization we may assume there exists an $a \in A$ such
that $\beta^p = a$. Set $A' = A[x]/(x^p - a)$.
Then $S' = \Spec(A') \to \Spec(A) = S$ is finite, surjective, and
universally injective. Moreover, if $\mathfrak p' \subset A'$
denotes the unique prime ideal lying over $\mathfrak p$,
then $A'_{\mathfrak p'} = k(\beta)$ and $k'/k(\beta)$
has smaller degree. Thus after replacing $S$ by $S'$
and $\eta$ by the point $\eta'$ corresponding to $\mathfrak p'$
we see that the degree of $k'$ over the residue field of $\eta$
has decreased. Continuing like this, by induction we reduce
to the case $k' = \kappa(\mathfrak p) = \kappa(\eta)$.

\medskip\noindent
Thus we may assume $S$ is affine, reduced, and that we have a diagram
$$
\xymatrix{
\overline{Y}_{1, \eta} \amalg \ldots \amalg \overline{Y}_{n, \eta} \ar[rd] &
Y_{1, \eta} \amalg \ldots \amalg Y_{n, \eta} \ar[r]_-\nu \ar[d] \ar[l]^j &
X_\eta \ar[d] \\
& \Spec(k_1) \amalg \ldots \amalg \Spec(k_n) \ar[r] &
\eta
}
$$
of schemes with the following properties:
\begin{enumerate}
\item $\nu$ is the normalization of $X_\eta$,
\item $j$ is an open immersion with dense image,
\item $k_i/\kappa(\eta)$
is a finite separable extension for $i = 1, \ldots, n$,
\item $\overline{Y}_{i, \eta}$ is smooth, projective, and
geometrically irreducible of dimension $\leq 1$ over $k_i$.
\end{enumerate}
Recall that $\kappa(\eta) = \kappa(\mathfrak p) = A_\mathfrak p$ is
the filtered colimit of $A_a$ for $a \in A$, $a \not \in \mathfrak p$.
See Algebra, Lemma \ref{algebra-lemma-localization-colimit}.
Thus we can descend the diagram above to a corresponding diagram
over $\Spec(A_a)$ for some $a \in A$, $a \not \in \mathfrak p$.
More precisely, after replacing $S$ by $\Spec(A_a)$
we may assume we have a commutative diagram
$$
\xymatrix{
\overline{Y}_1 \amalg \ldots \amalg \overline{Y}_n \ar[rd] &
Y_1 \amalg \ldots \amalg Y_n \ar[r]_-\nu \ar[d] \ar[l]^j &
X \ar[d] \\
& T_1 \amalg \ldots \amalg T_n \ar[r] & S
}
$$
of schemes whose base change to $\eta$ is the diagram above
with the following properties
\begin{enumerate}
\item $\nu$ is a finite, surjective morphism,
\item $j$ is an open immersion,
\item $T_i \to S$ is finite \'etale for $i = 1, \ldots, n$,
\item $Y_i \to T_i$ is smooth and surjective,
\item $\overline{Y}_i \to T_i$ is smooth and proper and has
geometrically connected fibres of dimension $\leq 1$.
\end{enumerate}
For this we first use
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
to obtain the diagram base changing to the previous diagram.
Then we use Limits, Lemmas \ref{limits-lemma-descend-etale},
\ref{limits-lemma-descend-smooth},
\ref{limits-lemma-descend-finite-finite-presentation},
\ref{limits-lemma-limit-affine},
\ref{limits-lemma-descend-open-immersion},
\ref{limits-lemma-eventually-proper}, and
\ref{limits-lemma-descend-surjective}
to obtain $\nu$ finite, surjective, $j$ open immersion, $T_i \to S$ finite
\'etale, $Y_i \to T$ smooth, $\overline{Y}_i \to T_i$ proper and
smooth. Since $Y_i$ cannot be empty, since smooth morphisms
are open, and since $T_i \to S$ is finite \'etale, after shrinking $S$
we may assume $Y_i \to T_i$ is surjective. Finally, the fibre of
$\overline{Y}_i \to T_i$ over the unique point $\eta_i = \Spec(k_i)$ 
of $T_i$ lying over $\eta$ is geometrically connected.
Hence by another shrinking we may assume the same thing is
true for all fibres, see
Lemma \ref{lemma-proper-flat-geom-red}.

\medskip\noindent
It remains to prove the existence of an open $W \subset X$
satisfying (a), (b), and (c). Since $\nu_\eta : \coprod Y_{i, \eta} \to X_\eta$
is the normalization morphism, we know by
Varieties, Lemma \ref{varieties-lemma-normalization-locally-algebraic}
there exists a dense open $W_\eta \subset X_\eta$
such that $\nu^{-1}(W_\eta) \to W_\eta$ is equal to
the inclusion of the reduction of $W_\eta$ into $W_\eta$.
Let $W \subset X$ be a quasi-compact open whose fibre
over $\eta$ is the open $W_\eta$ we just found.
After replacing $A = \Gamma(S, \mathcal{O}_S)$
by another localization we may assume $\nu^{-1}(W) \to W$
is a closed immersion, see Limits, Lemma
\ref{limits-lemma-descend-closed-immersion-finite-presentation}.
Since $\nu$ is also surjective we conclude
$\nu^{-1}(W) \to W$ is a thickening.
Set $W_i = \nu^{-1}(W) \cap Y_i$.
Shrinking $S$ once more we can assume $W_i \to T_i$ is
surjective for all $i$ (same argument as above).
Then we find that $W_i \subset Y_i$
is dense in all fibres of $Y_i \to T_i$ as $Y_i \to T_i$ has
geometrically irreducible fibres.
Since $\nu$ is finite and surjective, it then follows
that $W = \nu(\nu^{-1}(W))$ is dense in all fibres
of $X \to S$ too.
\end{proof}













\section{Descending separated locally quasi-finite morphisms}
\label{section-separated-locally-quasi-finite}

\noindent
In this section we show that ``separated locally quasi-finite morphisms
satisfy descent for fppf-coverings''. See Descent, Definition
\ref{descent-definition-descending-types-morphisms} for terminology.
This is in the marvellous
(for many reasons) paper by Raynaud and Gruson hidden in the proof
of \cite[Lemma 5.7.1]{GruRay}.
It can also be found in \cite{Murre-representation}, and
\cite[Expos\'e X, Lemma 5.4]{SGA3}
under the additional
hypothesis that the morphism is locally of finite presentation.
Here is the formal statement.

\begin{lemma}
\label{lemma-separated-locally-quasi-finite-morphisms-fppf-descend}
Let $S$ be a scheme.
Let $\{X_i \to S\}_{i\in I}$ be an fppf covering, see
Topologies, Definition \ref{topologies-definition-fppf-covering}.
Let $(V_i/X_i, \varphi_{ij})$ be a descent datum
relative to $\{X_i \to S\}$. If each morphism
$V_i \to X_i$ is separated and locally quasi-finite,
then the descent datum is effective.
\end{lemma}

\begin{proof}
Being separated and being locally quasi-finite
are properties of morphisms of schemes
which are preserved under any base change, see
Schemes, Lemma \ref{schemes-lemma-separated-permanence} and
Morphisms, Lemma \ref{morphisms-lemma-base-change-quasi-finite}.
Hence Descent, Lemma \ref{descent-lemma-descending-types-morphisms}
applies and it suffices to prove the statement of the lemma
in case the fppf-covering is given by a single
$\{X \to S\}$ flat surjective morphism of finite presentation of affines.
Say $X = \Spec(A)$ and $S = \Spec(R)$ so
that $R \to A$ is a faithfully flat ring map.
Let $(V, \varphi)$ be a descent datum relative to $X$ over $S$
and assume that $\pi : V \to X$ is separated and
locally quasi-finite.

\medskip\noindent
Let $W^1 \subset V$ be any affine open.
Consider $W = \text{pr}_1(\varphi(W^1 \times_S X)) \subset V$.
Here is a picture
$$
\xymatrix{
W^1 \times_S X \ar[rrrrr] \ar[ddd] \ar[rd]
& & & & &
\varphi(W^1 \times_S X) \ar[ddd] \ar[ld] \\
& V \times_S X \ar[rrr]^\varphi \ar[rd] \ar[dd]
& & &
X \times_S V \ar[ld] \ar[dd] & \\
& &
X \times_S X \ar[r]^1 \ar[d]_{\text{pr}_0}
&
X \times_S X \ar[d]^{\text{pr}_1}
& & \\
W^1 \ar[r] &
V \ar[r] &
X &
X &
V \ar[l] &
W \ar[l]
}
$$
Ok, and now since $X \to S$ is flat and of finite presentation it
is universally open (Morphisms, Lemma \ref{morphisms-lemma-fppf-open}).
Hence we conclude that $W$ is open. Moreover, it is
also clearly the case that $W$ is quasi-compact, and
$W^1 \subset W$. Moreover, we note that
$\varphi(W \times_S X) = X \times_S W$ by the cocycle
condition for $\varphi$. Hence we obtain a new descent datum
$(W, \varphi')$ by restricting $\varphi$ to $W \times_S X$.
Note that the morphism $W \to X$ is quasi-compact, separated
and locally quasi-finite. This implies that it is
separated and quasi-finite by definition. Hence it is quasi-affine by
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
Thus by
Descent, Lemma \ref{descent-lemma-quasi-affine}
we see that the descent datum
$(W, \varphi')$ is effective.

\medskip\noindent
In other words, we find that there exists an open covering
$V = \bigcup W_i$ by quasi-compact opens $W_i$ which are
stable for the descent morphism $\varphi$.
Moreover, for each such quasi-compact open $W \subset V$
the corresponding descent data $(W, \varphi')$ is effective.
This means the original descent datum is effective by glueing the
schemes obtained from descending the opens $W_i$, see
Descent, Lemma \ref{descent-lemma-effective-for-fpqc-is-local-upstairs}.
\end{proof}






\section{Relative finite presentation}
\label{section-finite-type-finite-presentation}

\noindent
Let $R \to A$ be a finite type ring map. Let $M$ be an $A$-module. In
More on Algebra,
Section \ref{more-algebra-section-relative-finite-presentation}
we defined what it means for $M$ to be finitely presented relative to $R$.
We also proved this notion has good localization properties and glues.
Hence we can define the corresponding global notion as follows.

\begin{definition}
\label{definition-relatively-finitely-presented-sheaf}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module. We say
$\mathcal{F}$ is {\it finitely presented relative to $S$} or
{\it of finite presentation relative to $S$}
if there exists an affine open covering $S = \bigcup V_i$ and
for every $i$ an affine open covering
$f^{-1}(V_i) = \bigcup_j U_{ij}$ such that $\mathcal{F}(U_{ij})$
is a $\mathcal{O}_X(U_{ij})$-module of finite presentation relative
to $\mathcal{O}_S(V_i)$.
\end{definition}

\noindent
Note that this implies that $\mathcal{F}$ is a finite type
$\mathcal{O}_X$-module. If $X \to S$ is just locally of finite
type, then $\mathcal{F}$ may be of finite presentation relative
to $S$, without $X \to S$ being locally of finite presentation.
We will see that $X \to S$ is locally of finite presentation if
and only if $\mathcal{O}_X$ is of finite presentation relative to $S$.

\begin{lemma}
\label{lemma-relative-finite-presentation-characterize}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module. The following
are equivalent
\begin{enumerate}
\item $\mathcal{F}$ is of finite presentation relative to $S$,
\item for every affine opens $U \subset X$, $V \subset S$
with $f(U) \subset V$ the $\mathcal{O}_X(U)$-module $\mathcal{F}(U)$
is finitely presented relative to $\mathcal{O}_S(V)$.
\end{enumerate}
Moreover, if this is true, then for every open subschemes
$U \subset X$ and $V \subset S$ with $f(U) \subset V$
the restriction $\mathcal{F}|_U$ is of finite presentation relative to $V$.
\end{lemma}

\begin{proof}
The final statement is clear from the equivalence of (1) and (2).
It is also clear that (2) implies (1). Assume (1) holds.
Let $S = \bigcup V_i$ and $f^{-1}(V_i) = \bigcup U_{ij}$ be
affine open coverings as in
Definition \ref{definition-relatively-finitely-presented-sheaf}.
Let $U \subset X$ and $V \subset S$ be as in (2).
By More on Algebra, Lemma
\ref{more-algebra-lemma-glue-relative-finite-presentation}
it suffices to find a standard open covering $U = \bigcup U_k$ of $U$
such that $\mathcal{F}(U_k)$ is finitely presented relative to
$\mathcal{O}_S(V)$. In other words, for every $u \in U$ it suffices
to find a standard affine open $u \in U' \subset U$ such that
$\mathcal{F}(U')$ is finitely presented relative to $\mathcal{O}_S(V)$.
Pick $i$ such that $f(u) \in V_i$ and then pick $j$ such that
$u \in U_{ij}$. By
Schemes, Lemma \ref{schemes-lemma-standard-open-two-affines}
we can find $v \in V' \subset V \cap V_i$ which is standard affine
open in $V'$ and $V_i$. Then $f^{-1}V'  \cap U$, resp.\ $f^{-1}V' \cap U_{ij}$
are standard affine opens of $U$, resp.\ $U_{ij}$.
Applying the lemma again we can find
$u \in U' \subset f^{-1}V' \cap U \cap U_{ij}$ which is standard affine
open in both $f^{-1}V'  \cap U$ and $f^{-1}V' \cap U_{ij}$.
Thus $U'$ is also a standard affine open of $U$ and $U_{ij}$.
By More on Algebra, Lemma
\ref{more-algebra-lemma-localize-relative-finite-presentation}
the assumption that $\mathcal{F}(U_{ij})$ is finitely presented
relative to $\mathcal{O}_S(V_i)$ implies that
$\mathcal{F}(U')$ is finitely presented relative to $\mathcal{O}_S(V_i)$.
Since $\mathcal{O}_X(U') =
\mathcal{O}_X(U') \otimes_{\mathcal{O}_S(V_i)} \mathcal{O}_S(V')$
we see from More on Algebra, Lemma
\ref{more-algebra-lemma-base-change-relative-finite-presentation}
that $\mathcal{F}(U')$ is finitely presented relative to $\mathcal{O}_S(V')$.
Applying More on Algebra, Lemma
\ref{more-algebra-lemma-localize-relative-finite-presentation}
again we conclude that
$\mathcal{F}(U')$ is finitely presented relative to $\mathcal{O}_S(V)$.
This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-relative-finite-presentation}
Let $f : X \to S$ be a morphism of schemes which is locally of finite
type. Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
\begin{enumerate}
\item If $f$ is locally of finite presentation, then $\mathcal{F}$
is of finite presentation relative to $S$ if and only if $\mathcal{F}$
is of finite presentation.
\item The morphism $f$ is locally of finite presentation if and only
if $\mathcal{O}_X$ is of finite presentation relative to $S$.
\end{enumerate}
\end{lemma}

\begin{proof}
Follows immediately from the definitions, see
discussion following
More on Algebra, Definition
\ref{more-algebra-definition-relatively-finitely-presented}.
\end{proof}

\begin{lemma}
\label{lemma-finite-morphism-relative-finite-presentation}
Let $\pi : X \to Y$ be a finite morphism of schemes locally of finite
type over a base scheme $S$. Let $\mathcal{F}$ be a quasi-coherent
$\mathcal{O}_X$-module. Then $\mathcal{F}$ is of finite presentation
relative to $S$ if and only if $\pi_*\mathcal{F}$ is of finite presentation
relative to $S$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma \ref{more-algebra-lemma-finite-extension}
into the language of schemes.
\end{proof}

\begin{lemma}
\label{lemma-base-change-relative-finite-presentation}
Let $f : X \to S$ be a morphism of schemes which is locally of finite
type. Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
Let $S' \to S$ be a morphism of schemes, set $X' = X \times_S S'$
and denote $\mathcal{F}'$ the pullback of $\mathcal{F}$ to $X'$.
If $\mathcal{F}$ is of finite presentation relative to $S$, then
$\mathcal{F}'$ is of finite presentation relative to $S'$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-base-change-relative-finite-presentation}
into the language of schemes.
\end{proof}

\begin{lemma}
\label{lemma-pull-relative-finite-presentation}
Let $X \to Y \to S$ be morphisms of schemes which are locally of finite
type. Let $\mathcal{G}$ be a quasi-coherent $\mathcal{O}_Y$-module.
If $f : X \to Y$ is locally of finite presentation and
$\mathcal{G}$ of finite presentation relative to $S$, then
$f^*\mathcal{G}$ is of finite presentation relative to $S$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-pull-relative-finite-presentation}
into the language of schemes.
\end{proof}

\begin{lemma}
\label{lemma-composition-relative-finite-presentation}
Let $X \to Y \to S$ be morphisms of schemes which are locally of finite
type. Let $\mathcal{F}$ be a quasi-coherent $\mathcal{O}_X$-module.
If $Y \to S$ is locally of finite presentation and $\mathcal{F}$
is of finite presentation relative to $Y$, then $\mathcal{F}$
is of finite presentation relative to $S$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-composition-relative-finite-presentation}
into the language of schemes.
\end{proof}

\begin{lemma}
\label{lemma-ses-relatively-finite-presentation}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $0 \to \mathcal{F}' \to \mathcal{F} \to \mathcal{F}'' \to 0$
be a short exact sequence of quasi-coherent $\mathcal{O}_X$-modules.
\begin{enumerate}
\item If $\mathcal{F}', \mathcal{F}''$ are finitely presented relative to
$S$, then so is $\mathcal{F}$.
\item If $\mathcal{F}'$ is a finite type $\mathcal{O}_X$-module
and $\mathcal{F}$ is finitely presented relative to $S$, then
$\mathcal{F}''$ is finitely presented relative to $S$.
\end{enumerate}
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-ses-relatively-finite-presentation}
into the language of schemes.
\end{proof}

\begin{lemma}
\label{lemma-sum-relatively-finite-presentation}
\begin{slogan}
A direct summand of a module inherits the property of being finitely
presented relative to a base.
\end{slogan}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}, \mathcal{F}'$ be quasi-coherent $\mathcal{O}_X$-modules.
If $\mathcal{F} \oplus \mathcal{F}'$ is finitely presented relative to $S$,
then so are $\mathcal{F}$ and $\mathcal{F}'$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-sum-relatively-finite-presentation}
into the language of schemes.
\end{proof}










\section{Relative pseudo-coherence}
\label{section-relative-pseudo-coherence}

\noindent
This section is the analogue of
More on Algebra, Section \ref{more-algebra-section-relative-pseudo-coherent}
for schemes. We strongly urge the reader to take a look at that
section first. Although we have developed the material in this section
and the material on pseudo-coherent complexes in
Cohomology, Sections \ref{cohomology-section-strictly-perfect},
\ref{cohomology-section-pseudo-coherent},
\ref{cohomology-section-tor}, and
\ref{cohomology-section-perfect}
for arbitrary complexes of $\mathcal{O}_X$-modules, if
$X$ is a scheme then working exclusively with objects in
$D_\QCoh(\mathcal{O}_X)$
greatly simplifies many of the lemmmas and arguments, often
reducing the problem at hand immediately to the algebraic counterpart.
Moreover, one of the first thing we do is to show that
being relatively pseudo-coherent implies the cohomology
sheaves are quasi-coherent, see Lemma \ref{lemma-relative-pseudo-coherence}.
Hence, on a first reading we suggest the reader work exclusively
with objects in $D_\QCoh(\mathcal{O}_X)$.

\begin{lemma}
\label{lemma-relatively-pseudo-coherent}
Let $X \to S$ be a finite type morphism of affine schemes.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Let $m \in \mathbf{Z}$.
The following are equivalent
\begin{enumerate}
\item for some closed immersion $i : X \to \mathbf{A}^n_S$
the object $Ri_*E$ of $D(\mathcal{O}_{\mathbf{A}^n_S})$
is $m$-pseudo-coherent, and
\item for all closed immersions $i : X \to \mathbf{A}^n_S$
the object $Ri_*E$ of $D(\mathcal{O}_{\mathbf{A}^n_S})$
is $m$-pseudo-coherent.
\end{enumerate}
\end{lemma}

\begin{proof}
Say $S = \Spec(R)$ and $X = \Spec(A)$. Let $i$ correspond to the surjection
$\alpha : R[x_1, \ldots, x_n] \to A$ and let $X \to \mathbf{A}^m_S$
correspond to $\beta : R[y_1, \ldots, y_m] \to A$.
Choose $f_j \in R[x_1, \ldots, x_n]$ with $\alpha(f_j) = \beta(y_j)$
and $g_i \in R[y_1, \ldots, y_m]$ with $\beta(g_i) = \alpha(x_i)$.
Then we get a commutative diagram
$$
\xymatrix{
R[x_1, \ldots, x_n, y_1, \ldots, y_m]
\ar[d]^{x_i \mapsto g_i} \ar[rr]_-{y_j \mapsto f_j} & &
R[x_1, \ldots, x_n] \ar[d] \\
R[y_1, \ldots, y_m] \ar[rr] & & A
}
$$
corresponding to the commutative diagram of closed immersions
$$
\xymatrix{
\mathbf{A}^{n + m}_S & \mathbf{A}^n_S \ar[l] \\
\mathbf{A}^m_S \ar[u] & X \ar[u] \ar[l]
}
$$
Thus it suffices to show that under a closed immersion
$$
f : \mathbf{A}^m_S \to \mathbf{A}^{n + m}_S
$$
an object $E$ of $D(\mathcal{O}_{\mathbf{A}^m_S})$ is
$m$-pseudo-coherent if and only if $Rf_*E$ is $m$-pseudo-coherent.
This follows from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-closed-push-pseudo-coherent}
and the fact that $f_*\mathcal{O}_{\mathbf{A}^m_S}$ is
a pseudo-coherent $\mathcal{O}_{\mathbf{A}^{n + m}_S}$-module.
The pseudo-coherence of $f_*\mathcal{O}_{\mathbf{A}^m_S}$ is
straightforward to prove directly, but it also follows from
Derived Categories of Schemes, Lemma \ref{perfect-lemma-pseudo-coherent-affine}
and
More on Algebra, Lemma \ref{more-algebra-lemma-relatively-pseudo-coherent}.
\end{proof}

\noindent
Recall that if $f : X \to S$ is a morphism of scheme which is locally of
finite type, then for every pair of affine opens $U \subset X$ and
$V \subset S$ such that $f(U) \subset V$, the ring map
$\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is of finite type
(Morphisms, Lemma \ref{morphisms-lemma-locally-finite-type-characterize}).
Hence there always exist closed
immersions $U \to \mathbf{A}^n_V$ and the following definition makes sense.

\begin{definition}
\label{definition-relative-pseudo-coherence}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $E$ be an object of $D(\mathcal{O}_X)$. Let $\mathcal{F}$ be an
$\mathcal{O}_X$-module. Fix $m \in \mathbf{Z}$.
\begin{enumerate}
\item We say $E$ is {\it $m$-pseudo-coherent relative to $S$}
if there exists an affine open covering $S = \bigcup V_i$ and
for each $i$ an affine open covering $f^{-1}(V_i) = \bigcup U_{ij}$
such that the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for each of the pairs $(U_{ij} \to V_i, E|_{U_{ij}})$.
\item We say $E$ is {\it pseudo-coherent relative to $S$}
if $E$ is $m$-pseudo-coherent relative to $S$ for all $m \in \mathbf{Z}$.
\item We say $\mathcal{F}$ is {\it $m$-pseudo-coherent relative to $S$} if
$\mathcal{F}$ viewed as an object of $D(\mathcal{O}_X)$ is
$m$-pseudo-coherent relative to $S$.
\item We say $\mathcal{F}$ is {\it pseudo-coherent relative to $S$} if
$\mathcal{F}$ viewed as an object of $D(\mathcal{O}_X)$ is
pseudo-coherent relative to $S$.
\end{enumerate}
\end{definition}

\noindent
If $X$ is quasi-compact and $E$ is $m$-pseudo-coherent relative to $S$
for some $m$, then $E$ is bounded above. If $E$ is
pseudo-coherent relative to $S$, then $E$ has
quasi-coherent cohomology sheaves.

\begin{lemma}
\label{lemma-relative-pseudo-coherence}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
If $E$ in $D(\mathcal{O}_X)$ is $m$-pseudo-coherent relative to $S$,
then $H^i(E)$ is a quasi-coherent $\mathcal{O}_X$-module for $i > m$.
If $E$ is pseudo-coherent relative to $S$, then $E$ is an object of
$D_\QCoh(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
Choose an affine open covering $S = \bigcup V_i$ and
for each $i$ an affine open covering $f^{-1}(V_i) = \bigcup U_{ij}$
such that the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for each of the pairs $(U_{ij} \to V_i, E|_{U_{ij}})$.
Since being quasi-coherent is local on $X$, we may assume
that there exists an closed immersion $i : X \to \mathbf{A}^n_S$
such that $Ri_*E$ is $m$-pseudo-coherent on $\mathbf{A}^n_S$.
By Derived Categories of Schemes, Lemma \ref{perfect-lemma-pseudo-coherent}
this means that $H^q(Ri_*E)$ is quasi-coherent for $q > m$.
Since $i_*$ is an exact functor, we have $i_*H^q(E) = H^q(Ri_*E)$
is quasi-coherent on $\mathbf{A}^n_S$.
By Morphisms, Lemma \ref{morphisms-lemma-i-star-equivalence}
this implies that $H^q(E)$ is quasi-coherent as desired
(strictly speaking it implies there exists some quasi-coherent
$\mathcal{O}_X$-module $\mathcal{F}$ such that
$i_*\mathcal{F} = i_*H^q(E)$ and then
Modules, Lemma \ref{modules-lemma-i-star-equivalence}
tells us that $\mathcal{F} \cong H^q(E)$ hence the result).
\end{proof}

\noindent
Next, we prove the condition of relative pseudo-coherence localizes well.

\begin{lemma}
\label{lemma-localize-relative-pseudo-coherent}
Let $S$ be an affine scheme. Let $V \subset S$ be a standard open.
Let $X \to V$ be a finite type morphism of affine schemes.
Let $U \subset X$ be an affine open. Let $E$ be an object of
$D(\mathcal{O}_X)$. If the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(X \to V, E)$, then
the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(U \to S, E|_U)$.
\end{lemma}

\begin{proof}
Write $S = \Spec(R)$, $V = D(f)$, $X = \Spec(A)$, and $U = D(g)$.
Assume the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(X \to V, E)$.

\medskip\noindent
Choose $R_f[x_1, \ldots, x_n] \to A$ surjective. Write
$R_f = R[x_0]/(fx_0 - 1)$. Then $R[x_0, x_1, \ldots, x_n] \to A$
is surjective, and $R_f[x_1, \ldots, x_n]$ is pseudo-coherent as
an $R[x_0, \ldots, x_n]$-module. Thus we have
$$
X \to \mathbf{A}^n_V \to \mathbf{A}^{n + 1}_S
$$
and we can apply
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-closed-push-pseudo-coherent}
to conclude that the pushforward $E'$ of $E$ to $\mathbf{A}^{n + 1}_S$
is $m$-pseudo-coherent.

\medskip\noindent
Choose an element $g' \in R[x_0, x_1, \ldots, x_n]$ which maps to
$g \in A$. Consider the surjection
$R[x_0, \ldots, x_{n + 1}] \to R[x_0, \ldots, x_n, 1/g']$.
We obtain
$$
\xymatrix{
X \ar[d] & U \ar[d] \ar[l] \ar[dr] \\
\mathbf{A}^{n + 1}_S & D(g')\ar[l] \ar[r] & \mathbf{A}^{n + 2}_S
}
$$
where the lower left arrow is an open immersion and the lower right arrow is
a closed immersion. We conclude as before that the pushforward of
$E'|_{D(g')}$ to $\mathbf{A}^{n + 2}_S$ is $m$-pseudo-coherent.
Since this is also the pushforward of $E|_U$ to $\mathbf{A}^{n + 2}_S$
we conclude the lemma is true.
\end{proof}

\begin{lemma}
\label{lemma-glue-relative-pseudo-coherent}
Let $X \to S$ be a finite type morphism of affine schemes. Let $E$ be an
object of $D(\mathcal{O}_X)$. Let $m \in \mathbf{Z}$.
Let $X = \bigcup U_i$ be a standard affine open covering.
The following are equivalent
\begin{enumerate}
\item the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
hold for the pairs $(U_i \to S, E|_{U_i})$,
\item the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
hold for the pair $(X \to S, E)$.
\end{enumerate}
\end{lemma}

\begin{proof}
The implication (2) $\Rightarrow$ (1) is
Lemma \ref{lemma-localize-relative-pseudo-coherent}.
Assume (1). Say $S = \Spec(R)$ and $X = \Spec(A)$ and
$U_i = D(f_i)$. Write $1 = \sum f_ig_i$ in $A$.
Consider the surjections
$$
R[x_i, y_i, z_i] \to R[x_i, y_i, z_i]/(\sum y_iz_i - 1) \to A.
$$
which sends $y_i$ to $f_i$ and $z_i$ to $g_i$. Note that
$R[x_i, y_i, z_i]/(\sum y_iz_i - 1)$ is pseudo-coherent as an
$R[x_i, y_i, z_i]$-module. Thus it suffices to prove that
the pushforward of $E$ to $T = \Spec(R[x_i, y_i, z_i]/(\sum y_iz_i - 1))$
is $m$-pseudo-coherent, see
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-closed-push-pseudo-coherent}.
For each $i_0$ it suffices to prove the restriction of this
pushforward to
$W_{i_0} = \Spec(R[x_i, y_i, z_i, 1/y_{i_0}]/(\sum y_iz_i - 1))$
is $m$-pseudo-coherent. Note that there is a commutative diagram
$$
\xymatrix{
X \ar[d] & U_{i_0} \ar[l] \ar[d] \\
T & W_{i_0} \ar[l]
}
$$
which implies that the pushforward of $E$ to $T$ restricted to $W_{i_0}$
is the pushforward of $E|_{U_{i_0}}$ to $W_{i_0}$. Since
$R[x_i, y_i, z_i, 1/y_{i_0}]/(\sum y_iz_i - 1)$ is isomorphic
to a polynomial ring over $R$ this proves what we want.
\end{proof}

\begin{lemma}
\label{lemma-relative-pseudo-coherence-characterize}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $E$ be an object of $D(\mathcal{O}_X)$.
Fix $m \in \mathbf{Z}$. The following are equivalent
\begin{enumerate}
\item $E$ is $m$-pseudo-coherent relative to $S$,
\item for every affine opens $U \subset X$ and $V \subset S$
with $f(U) \subset V$ the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(U \to V, E|_U)$.
\end{enumerate}
Moreover, if this is true, then for every open subschemes
$U \subset X$ and $V \subset S$ with $f(U) \subset V$
the restriction $E|_U$ is $m$-pseudo-coherent relative to $V$.
\end{lemma}

\begin{proof}
The final statement is clear from the equivalence of (1) and (2).
It is also clear that (2) implies (1). Assume (1) holds.
Let $S = \bigcup V_i$ and $f^{-1}(V_i) = \bigcup U_{ij}$ be
affine open coverings as in
Definition \ref{definition-relative-pseudo-coherence}.
Let $U \subset X$ and $V \subset S$ be as in (2).
By Lemma \ref{lemma-glue-relative-pseudo-coherent}
it suffices to find a standard open covering $U = \bigcup U_k$ of $U$
such that the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pairs $(U_k \to V, E|_{U_k})$.
In other words, for every $u \in U$ it suffices
to find a standard affine open $u \in U' \subset U$ such that
the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(U' \to V, E|_{U'})$.
Pick $i$ such that $f(u) \in V_i$ and then pick $j$ such that
$u \in U_{ij}$. By
Schemes, Lemma \ref{schemes-lemma-standard-open-two-affines}
we can find $v \in V' \subset V \cap V_i$ which is standard affine
open in $V'$ and $V_i$. Then $f^{-1}V'  \cap U$, resp.\ $f^{-1}V' \cap U_{ij}$
are standard affine opens of $U$, resp.\ $U_{ij}$.
Applying the lemma again we can find
$u \in U' \subset f^{-1}V' \cap U \cap U_{ij}$ which is standard affine
open in both $f^{-1}V'  \cap U$ and $f^{-1}V' \cap U_{ij}$.
Thus $U'$ is also a standard affine open of $U$ and $U_{ij}$.
By Lemma \ref{lemma-localize-relative-pseudo-coherent}
the assumption that the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(U_{ij} \to V_i, E|_{U_{ij}})$
implies that the equivalent conditions of
Lemma \ref{lemma-relatively-pseudo-coherent}
are satisfied for the pair $(U' \to V, E|_{U'})$.
\end{proof}

\noindent
For objects of the derived category whose cohomology sheaves are
quasi-coherent, we can relate relative $m$-pseudo-coherence
to the notion defined in More on Algebra, Definition
\ref{more-algebra-definition-relatively-pseudo-coherent}.
We will use the fact that for an affine scheme
$U = \Spec(A)$ the functor $R\Gamma(U, -)$ induces an equivalence
between $D_\QCoh(\mathcal{O}_U)$ and $D(A)$, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}.
This functor is compatible with pullbacks:
if $E$ is an object of $D_\QCoh(\mathcal{O}_U)$
and $A \to B$ is a ring map corresponding to a morphism of affine
schemes $g : V = \Spec(B) \to \Spec(A) = U$, then
$R\Gamma(V, Lg^*E) = R\Gamma(U, E) \otimes_A^\mathbf{L} B$.
See Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-pullback}.

\begin{lemma}
\label{lemma-qcoh-relative-pseudo-coherence-characterize}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $E$ be an object of $D_\QCoh(\mathcal{O}_X)$.
Fix $m \in \mathbf{Z}$. The following are equivalent
\begin{enumerate}
\item $E$ is $m$-pseudo-coherent relative to $S$,
\item there exists an affine open covering $S = \bigcup V_i$ and
for each $i$ an affine open covering $f^{-1}(V_i) = \bigcup U_{ij}$
such that the complex of $\mathcal{O}_X(U_{ij})$-modules
$R\Gamma(U_{ij}, E)$ is $m$-pseudo-coherent relative to
$\mathcal{O}_S(V_i)$, and
\item for every affine opens $U \subset X$ and $V \subset S$
with $f(U) \subset V$ the complex of $\mathcal{O}_X(U)$-modules
$R\Gamma(U, E)$ is $m$-pseudo-coherent relative to $\mathcal{O}_S(V)$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $U$ and $V$ be as in (2) and choose a closed immersion
$i : U \to \mathbf{A}^n_V$. A formal argument, using
Lemma \ref{lemma-relative-pseudo-coherence-characterize}, shows it
suffices to prove that
$Ri_*(E|_U)$ is $m$-pseudo-coherent if and only if $R\Gamma(U, E)$
is $m$-pseudo-coherent relative to $\mathcal{O}_S(V)$.
Say $U = \Spec(A)$, $V = \Spec(R)$, and
$\mathbf{A}^n_V = \Spec(R[x_1, \ldots, x_n]$. By the remarks
preceding the lemma, $E|_U$ is quasi-isomorphic to the
complex of quasi-coherent sheaves on $U$ associated to the object
$R\Gamma(U, E)$ of $D(A)$. Note that
$R\Gamma(U, E) = R\Gamma(\mathbf{A}^n_V, Ri_*(E|_U))$ as $i$ is a
closed immersion (and hence $i_*$ is exact). Thus $Ri_*E$
is associated to $R\Gamma(U, E)$ viewed as an object of
$D(R[x_1, \ldots, x_n])$. We conclude as $m$-pseudo-coherence
of $Ri_*(E|_U)$ is equivalent to $m$-pseudo-coherence of
$R\Gamma(U, E)$ in $D(R[x_1, \ldots, x_n])$ by
Derived Categories of Schemes, Lemma \ref{perfect-lemma-pseudo-coherent-affine}
which is equivalent to $R\Gamma(U, E)$ is $m$-pseudo-coherent
relative to $R = \mathcal{O}_S(V)$ by definition.
\end{proof}

\begin{lemma}
\label{lemma-closed-morphism-relative-pseudo-coherence}
Let $i : X \to Y$ morphism of schemes locally of finite type over a
base scheme $S$. Assume that $i$ induces a homeomorphism of $X$ with a closed
subset of $Y$. Let $E$ be an object of $D(\mathcal{O}_X)$.
Then $E$ is $m$-pseudo-coherent relative to $S$ if and only if
$Ri_*E$ is $m$-pseudo-coherent relative to $S$.
\end{lemma}

\begin{proof}
By Morphisms, Lemma \ref{morphisms-lemma-homeomorphism-affine}
the morphism $i$ is affine. Thus we may assume $S$, $Y$, and $X$ are affine.
Say $S = \Spec(R)$, $Y = \Spec(A)$, and $X = \Spec(B)$.
The condition means that $A/\text{rad}(A) \to B/\text{rad}(B)$ is
surjective; here $\text{rad}(A)$ and $\text{rad}(B)$ denote
the Jacobson radical of $A$ and $B$.
As $B$ is of finite type over $A$, we can find
$b_1, \ldots, b_m \in \text{rad}(B)$ which generate $B$ as an
$A$-algebra. Say $b_j^N = 0$ for all $j$. Consider the diagram of
rings
$$
\xymatrix{
B & R[x_i, y_j]/(y_j^N) \ar[l] & R[x_i, y_j] \ar[l] \\
A \ar[u] & R[x_i] \ar[l] \ar[u] \ar[ru]
}
$$
which translates into a diagram
$$
\xymatrix{
X \ar[d] \ar[r] & T \ar[d] \ar[r] & \mathbf{A}^{n + m}_S \ar[ld] \\
Y \ar[r] & \mathbf{A}^n_S
}
$$
of affine schemes. By Lemma \ref{lemma-relative-pseudo-coherence-characterize}
we see that $E$ is $m$-pseudo-coherent relative to $S$ if and only if its
pushforward to $\mathbf{A}^{n + m}_S$ is $m$-pseudo-coherent. 
By Derived Categories of Schemes, Lemma
\ref{perfect-lemma-closed-push-pseudo-coherent}
we see that this is true if and only if its pushforward to $T$ is
$m$-pseudo-coherent. The same lemma shows that this holds if and only
if the pushforward to $\mathbf{A}^n_S$ is $m$-pseudo-coherent.
Again by
Lemma \ref{lemma-relative-pseudo-coherence-characterize}
this holds if and only if $Ri_*E$ is $m$-pseudo-coherent relative to $S$.
\end{proof}

\begin{lemma}
\label{lemma-finite-morphism-relative-pseudo-coherence}
Let $\pi : X \to Y$ be a finite morphism of schemes locally of finite
type over a base scheme $S$. Let $E$ be an object of
$D_\QCoh(\mathcal{O}_X)$. Then $E$ is $m$-pseudo-coherent
relative to $S$ if and only if $R\pi_*E$ is $m$-pseudo-coherent
relative to $S$.
\end{lemma}

\begin{proof}
Translation of the result of
More on Algebra, Lemma
\ref{more-algebra-lemma-finite-extension-pseudo-coherent}
into the language of schemes. Observe that $R\pi_*$ indeed
maps $D_\QCoh(\mathcal{O}_X)$ into $D_\QCoh(\mathcal{O}_Y)$
by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-quasi-coherence-direct-image}.
To do the translation use
Lemma \ref{lemma-relative-pseudo-coherence-characterize}.
\end{proof}

\begin{lemma}
\label{lemma-cone-relatively-pseudo-coherent}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
Let $(E, E', E'')$ be a distinguished triangle of
$D(\mathcal{O}_X)$. Let $m \in \mathbf{Z}$.
\begin{enumerate}
\item If $E$ is $(m + 1)$-pseudo-coherent relative to $S$ and
$E'$ is $m$-pseudo-coherent relative to $S$ then $E''$ is
$m$-pseudo-coherent relative to $S$.
\item If $E, E''$ are $m$-pseudo-coherent relative to $S$,
then $E'$ is $m$-pseudo-coherent relative to $S$.
\item If $E'$ is $(m + 1)$-pseudo-coherent relative to $S$
and $E''$ is $m$-pseudo-coherent relative to $S$, then
$E$ is $(m + 1)$-pseudo-coherent relative to $S$.
\end{enumerate}
Moreover, if two out of three of $E, E', E''$ are pseudo-coherent
relative to $S$, the so is the third.
\end{lemma}

\begin{proof}
Immediate from Lemma \ref{lemma-relative-pseudo-coherence-characterize} and
Cohomology, Lemma \ref{cohomology-lemma-cone-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-rel-n-pseudo-module}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $\mathcal{F}$ be an $\mathcal{O}_X$-module. Then
\begin{enumerate}
\item $\mathcal{F}$ is $m$-pseudo-coherent relative to $S$ for all $m > 0$,
\item $\mathcal{F}$ is $0$-pseudo-coherent relative to $S$ if and only if
$\mathcal{F}$ is a finite type $\mathcal{O}_X$-module,
\item $\mathcal{F}$ is $(-1)$-pseudo-coherent relative to $S$ if and only if
$\mathcal{F}$ is quasi-coherent and finitely presented relative to $S$.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) is immediate from the definition. To see part (3)
we may work locally on $X$ (both properties are local). Thus we
may assume $X$ and $S$ are affine. Choose a closed immersion
$i : X \to \mathbf{A}^n_S$. Then we see that $\mathcal{F}$ is
$(-1)$-pseudo-coherent relative to $S$ if and only if $i_*\mathcal{F}$
is $(-1)$-pseudo-coherent, which is true if and only if $i_*\mathcal{F}$
is an $\mathcal{O}_{\mathbf{A}^n_S}$-module of finite presentation, see
Cohomology, Lemma \ref{cohomology-lemma-finite-cohomology}.
A module of finite presentation is quasi-coherent, see
Modules, Lemma \ref{modules-lemma-finite-presentation-quasi-coherent}.
By Morphisms, Lemma \ref{morphisms-lemma-i-star-equivalence}
we see that $\mathcal{F}$ is quasi-coherent if and only if $i_*\mathcal{F}$
is quasi-coherent. Having said this part (3) follows. The proof of (2)
is similar but less involved.
\end{proof}

\begin{lemma}
\label{lemma-summands-relative-pseudo-coherent}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $m \in \mathbf{Z}$. Let $E, K$ be objects of $D(\mathcal{O}_X)$.
If $E \oplus K$ is $m$-pseudo-coherent relative to $S$ so are $E$ and $K$.
\end{lemma}

\begin{proof}
Follows from
Cohomology, Lemma \ref{cohomology-lemma-summands-pseudo-coherent}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-complex-relative-pseudo-coherent-modules}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $m \in \mathbf{Z}$. Let $\mathcal{F}^\bullet$ be a (locally) bounded
above complex of $\mathcal{O}_X$-modules such that $\mathcal{F}^i$ is
$(m - i)$-pseudo-coherent relative to $S$ for all $i$. Then
$\mathcal{F}^\bullet$ is $m$-pseudo-coherent relative to $S$.
\end{lemma}

\begin{proof}
Follows from
Cohomology, Lemma \ref{cohomology-lemma-complex-pseudo-coherent-modules}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-cohomology-relative-pseudo-coherent}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $m \in \mathbf{Z}$. Let $E$ be an object of $D(\mathcal{O}_X)$.
If $E$ is (locally) bounded above and $H^i(E)$ is $(m - i)$-pseudo-coherent
relative to $S$ for all $i$, then $E$ is $m$-pseudo-coherent relative to $S$.
\end{lemma}

\begin{proof}
Follows from
Cohomology, Lemma \ref{cohomology-lemma-cohomology-pseudo-coherent}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-base-change-relative-pseudo-coherent}
Let $X \to S$ be a morphism of schemes which is locally of finite type.
Let $m \in \mathbf{Z}$. Let $E$ be an object of $D(\mathcal{O}_X)$
which is $m$-pseudo-coherent relative to $S$. Let $S' \to S$ be a
morphism of schemes. Set $X' = X \times_S S'$ and denote $E'$
the derived pullback of $E$ to $X'$. If $S'$ and $X$ are
Tor independent over $S$, then $E'$
is $m$-pseudo-coherent relative to $S'$.
\end{lemma}

\begin{proof}
The problem is local on $X$ and $X'$ hence we may assume $X$, $S$, $S'$,
and $X'$ are affine. Choose a closed immersion $i : X \to \mathbf{A}^n_S$
and denote $i' : X' \to \mathbf{A}^n_{S'}$ the base change to $S'$.
Denote $g : X' \to X$ and $g' : \mathbf{A}^n_{S'} \to \mathbf{A}^n_S$
the projections, so $E' = Lg^*E$. Since $X$ and $S'$ are tor-independent
over $S$, the base change map
(Cohomology, Remark \ref{cohomology-remark-base-change})
induces an isomorphism
$$
Ri'_*(Lg^*E) = L(g')^*Ri_*E
$$
Namely, for a point $x' \in X'$ lying over $x \in X$ the base change
map on stalks at $x'$ is the map
$$
E_x \otimes_{\mathcal{O}_{\mathbf{A}^n_S, x}}^\mathbf{L}
\mathcal{O}_{\mathbf{A}^n_{S'}, x'}
\longrightarrow
E_x \otimes_{\mathcal{O}_{X, x}}^\mathbf{L}
\mathcal{O}_{X', x'}
$$
coming from the closed immersions $i$ and $i'$. Note that the source
is quasi-isomorphic to a localization of
$E_x \otimes_{\mathcal{O}_{S, s}}^\mathbf{L} \mathcal{O}_{S', s'}$
which is isomorphic to the target as
$\mathcal{O}_{X', x'}$ is isomorphic to (the same) localization of
$\mathcal{O}_{X, x} \otimes_{\mathcal{O}_{S, s}}^\mathbf{L}
\mathcal{O}_{S', s'}$ by assumption. We conclude the lemma holds
by an application of
Cohomology, Lemma \ref{cohomology-lemma-pseudo-coherent-pullback}.
\end{proof}

\begin{lemma}
\label{lemma-pull-relative-pseudo-coherent}
Let $f : X \to Y$ be a morphism of schemes locally of finite type
over a base $S$. Let $m \in \mathbf{Z}$. Let $E$ be an object of
$D(\mathcal{O}_Y)$. Assume
\begin{enumerate}
\item $\mathcal{O}_X$ is pseudo-coherent relative to $Y$\footnote{This
means $f$ is pseudo-coherent, see
Definition \ref{definition-pseudo-coherent}.}, and
\item $E$ is $m$-pseudo-coherent relative to $S$.
\end{enumerate}
Then $Lf^*E$ is $m$-pseudo-coherent relative to $S$.
\end{lemma}

\begin{proof}
The problem is local on $X$. Thus we may assume $X$, $Y$, and $S$ are affine.
Arguing as in the proof of More on Algebra, Lemma
\ref{more-algebra-lemma-pull-relative-pseudo-coherent}
we can find a commutative diagram
$$
\xymatrix{
X \ar[r]_i \ar[d]_f &
\mathbf{A}^d_Y \ar[r]_j \ar[ld]^p &
\mathbf{A}^{n + d}_S \ar[ld] \\
Y \ar[r] &
\mathbf{A}^n_S
}
$$
Observe that
$$
Ri_* Lf^*E = Ri_* Li^* Lp^*E =
Lp^*E \otimes_{\mathcal{O}_{\mathbf{A}_Y^n}}^\mathbf{L} Ri_*\mathcal{O}_X
$$
by Cohomology, Lemma
\ref{cohomology-lemma-projection-formula-closed-immersion}.
By assumption and the fact that $Y$ is affine, we can represent
$Ri_*\mathcal{O}_X = i_*\mathcal{O}_X$ by a complexes of finite free
$\mathcal{O}_{\mathbf{A}_Y^n}$-modules $\mathcal{F}^\bullet$, with
$\mathcal{F}^q = 0$ for $q > 0$
(details omitted; use Derived Categories of Schemes, Lemma
\ref{perfect-lemma-pseudo-coherent-affine}
and
More on Algebra, Lemma
\ref{more-algebra-lemma-rel-n-pseudo-module}).
By assumption $E$ is bounded above, say $H^q(E) = 0$ for $q > a$.
Represent $E$ by a complex $\mathcal{E}^\bullet$ of $\mathcal{O}_Y$-modules
with $\mathcal{E}^q = 0$ for $q > a$. Then the derived tensor product above
is represented by $\text{Tot}(p^*\mathcal{E}^\bullet
\otimes_{\mathcal{O}_{\mathbf{A}_Y^n}} \mathcal{F}^\bullet)$.

\medskip\noindent
Since $j$ is a closed immersion, the functor $j_*$ is exact and
$Rj_*$ is computed by applying $j_*$ to any representating complex
of sheaves. Thus we have to show that
$j_*\text{Tot}(p^*\mathcal{E}^\bullet \otimes_{\mathcal{O}_{\mathbf{A}_Y^n}}
\mathcal{F}^\bullet)$ is $m$-pseudo-coherent
as a complex of $\mathcal{O}_{\mathbf{A}^{n + m}_S}$-modules.
Note that
$\text{Tot}(p^*\mathcal{E}^\bullet \otimes_{\mathcal{O}_{\mathbf{A}_Y^n}}
\mathcal{F}^\bullet)$ has a filtration by
subcomplexes with successive quotients the complexes
$p^*\mathcal{E}^\bullet
\otimes_{\mathcal{O}_{\mathbf{A}_Y^n}} \mathcal{F}^q[-q]$.
Note that for $q \ll 0$ the complexes
$p^*\mathcal{E}^\bullet \otimes_{\mathcal{O}_{\mathbf{A}_Y^n}}
\mathcal{F}^q[-q]$
have zero cohomology in degrees $\leq m$ and hence are $m$-pseudo-coherent.
Hence, applying
Lemma \ref{lemma-cone-relatively-pseudo-coherent}
and induction, it suffices to show that
$p^*\mathcal{E}^\bullet \otimes_{\mathcal{O}_{\mathbf{A}_Y^n}}
\mathcal{F}^q[-q]$
is pseudo-coherent relative to $S$ for all $q$. Note that $\mathcal{F}^q = 0$
for $q > 0$. Since also $\mathcal{F}^q$ is finite free this
reduces to proving that $p^*\mathcal{E}^\bullet$ is
$m$-pseudo-coherent relative to $S$ which follows from
Lemma \ref{lemma-base-change-relative-pseudo-coherent}
for instance.
\end{proof}

\begin{lemma}
\label{lemma-composition-relative-pseudo-coherent}
Let $f : X \to Y$ be a morphism of schemes locally of finite type
over a base $S$. Let $m \in \mathbf{Z}$. Let $E$ be an object of
$D(\mathcal{O}_X)$. Assume $\mathcal{O}_Y$ is pseudo-coherent relative
to $S$\footnote{This means $Y \to S$ is pseudo-coherent, see
Definition \ref{definition-pseudo-coherent}.}.
Then the following are equivalent
\begin{enumerate}
\item $E$ is $m$-pseudo-coherent relative to $Y$, and
\item $E$ is $m$-pseudo-coherent relative to $S$.
\end{enumerate}
\end{lemma}

\begin{proof}
The question is local on $X$, hence we may assume $X$, $Y$, and $S$ are affine.
Arguing as in the proof of More on Algebra, Lemma
\ref{more-algebra-lemma-pull-relative-pseudo-coherent}
we can find a commutative diagram
$$
\xymatrix{
X \ar[r]_i \ar[d]_f &
\mathbf{A}^m_Y \ar[r]_j \ar[ld]^p &
\mathbf{A}^{n + m}_S \ar[ld] \\
Y \ar[r] &
\mathbf{A}^n_S
}
$$
The assumption that $\mathcal{O}_Y$ is pseudo-coherent relative to $S$
implies that $\mathcal{O}_{\mathbf{A}^m_Y}$ is pseudo-coherent relative
to $\mathbf{A}^m_S$ (by flat base change; this can be seen by using
for example Lemma \ref{lemma-base-change-relative-pseudo-coherent}).
This in turn implies that $j_*\mathcal{O}_{\mathbf{A}^n_Y}$ is
pseudo-coherent as an
$\mathcal{O}_{\mathbf{A}^{n + m}_S}$-module. Then the equivalence of
the lemma follows from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-closed-push-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-check-relative-pseudo-coherence-on-charts}
Let
$$
\xymatrix{
X \ar[rd] \ar[rr]_i & & P \ar[ld] \\
& S
}
$$
be a commutative diagram of schemes. Assume $i$ is a closed immersion
and $P \to S$ flat and locally of finite presentation. Let $E$
be an object of $D(\mathcal{O}_X)$. Then the following
are equivalent
\begin{enumerate}
\item $E$ is $m$-pseudo-coherent relative to $S$,
\item $Ri_*E$ is $m$-pseudo-coherent relative to $S$, and
\item $Ri_*E$ is $m$-pseudo-coherent on $P$.
\end{enumerate}
\end{lemma}

\begin{proof}
The equivalence of (1) and (2) is
Lemma \ref{lemma-finite-morphism-relative-pseudo-coherence}.
The equivalence of (2) and (3) follows from
Lemma
\ref{lemma-composition-relative-pseudo-coherent}
applied to $\text{id} : P \to P$
provided we can show that $\mathcal{O}_P$ is
pseudo-coherent relative to $S$. This follows from
More on Algebra, Lemma
\ref{more-algebra-lemma-flat-finite-presentation-perfect}
and the definitions.
\end{proof}









\section{Pseudo-coherent morphisms}
\label{section-pseudo-coherent}

\noindent
Avoid reading this section at all cost.
If you need some of this material, first take a look at the
corresponding algebra sections, see
More on Algebra, Sections \ref{more-algebra-section-pseudo-coherent},
\ref{more-algebra-section-relative-pseudo-coherent}, and
\ref{more-algebra-section-pseudo-coherent-perfect-ring-map}.
For now the only thing you need to know is that a ring map
$A \to B$ is pseudo-coherent if and only if $B = A[x_1, \ldots, x_n]/I$
and $B$ as an $A[x_1, \ldots, x_n]$-module has a resolution by
finite free $A[x_1, \ldots, x_n]$-modules.

\begin{lemma}
\label{lemma-pseudo-coherent}
Let $f : X \to S$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item there exist an affine open covering $S = \bigcup V_j$ and for each $j$
an affine open covering $f^{-1}(V_j) = \bigcup U_{ji}$ such that
$\mathcal{O}_S(V_j) \to \mathcal{O}_X(U_{ij})$ is a pseudo-coherent
ring map,
\item for every pair of affine opens $U \subset X$, $V \subset S$
such that $f(U) \subset V$ the ring map
$\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is pseudo-coherent, and
\item $f$ is locally of finite type and $\mathcal{O}_X$
is pseudo-coherent relative to $S$.
\end{enumerate}
\end{lemma}

\begin{proof}
To see the equivalence of (1) and (2) it suffices to check conditions
(1)(a), (b), (c) of
Morphisms, Definition \ref{morphisms-definition-property-local}
for the property of being a pseudo-coherent ring map.
These properties follow (using localization is flat) from
More on Algebra, Lemmas
\ref{more-algebra-lemma-base-change-relative-pseudo-coherent},
\ref{more-algebra-lemma-localize-relative-pseudo-coherent}, and
\ref{more-algebra-lemma-glue-relative-pseudo-coherent}.

\medskip\noindent
If (1) holds, then $f$ is locally of finite type as a pseudo-coherent
ring map is of finite type by definition. Moreover, (1) implies
via Lemma \ref{lemma-qcoh-relative-pseudo-coherence-characterize}
and the definitions that $\mathcal{O}_X$ is pseudo-coherent
relative to $S$. Conversely, if (3) holds, then we see
that for every $U$ and $V$ as in (2) the ring
$\mathcal{O}_X(U)$ is of finite type over $\mathcal{O}_S(V)$
and $\mathcal{O}_X(U)$ is as a module
pseudo-coherent relative to $\mathcal{O}_S(V)$, see
Lemmas \ref{lemma-relative-pseudo-coherence-characterize} and
\ref{lemma-qcoh-relative-pseudo-coherence-characterize}.
This is the definition of a pseudo-coherent ring map, hence
(2) and (1) hold.
\end{proof}

\begin{definition}
\label{definition-pseudo-coherent}
A morphism of schemes $f : X \to S$ is called {\it pseudo-coherent}
if the equivalent conditions of
Lemma \ref{lemma-pseudo-coherent}
are satisfied. In this case we also say that $X$ is pseudo-coherent
over $S$.
\end{definition}

\noindent
Beware that a base change of a pseudo-coherent morphism is not
pseudo-coherent in general.

\begin{lemma}
\label{lemma-flat-base-change-pseudo-coherent}
A flat base change of a pseudo-coherent morphism is pseudo-coherent.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
Let $A \to B$ be a pseudo-coherent ring map.
Let $A \to A'$ be flat. Then $A' \to B \otimes_A A'$ is
pseudo-coherent. This follows from the more general
More on Algebra,
Lemma \ref{more-algebra-lemma-base-change-relative-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-composition-pseudo-coherent}
A composition of pseudo-coherent morphisms of schemes is
pseudo-coherent.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
If $A \to B \to C$ are composable pseudo-coherent ring maps
then $A \to C$ is pseudo-coherent. This follows from either
More on Algebra,
Lemma \ref{more-algebra-lemma-pull-relative-pseudo-coherent}
or
More on Algebra,
Lemma \ref{more-algebra-lemma-composition-relative-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-pseudo-coherent-finite-presentation}
A pseudo-coherent morphism is locally of finite presentation.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-pseudo-coherent}
A flat morphism which is locally of finite presentation is pseudo-coherent.
\end{lemma}

\begin{proof}
This follows from the fact that a flat ring map of finite presentation is
pseudo-coherent (and even perfect), see
More on Algebra,
Lemma \ref{more-algebra-lemma-flat-finite-presentation-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-permanence-pseudo-coherent}
Let $f : X \to Y$ be a morphism of schemes pseudo-coherent
over a base scheme $S$. Then $f$ is pseudo-coherent.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
If $R \to A \to B$ are composable ring maps
and $R \to A$, $R \to B$ pseudo-coherent, then
$R \to B$ is pseudo-coherent. This follows from
More on Algebra,
Lemma \ref{more-algebra-lemma-composition-relative-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-finite-pseudo-coherent}
Let $f : X \to S$ be a finite morphism of schemes.
Then $f$ is pseudo-coherent if and only if $f_*\mathcal{O}_X$
is pseudo-coherent as an $\mathcal{O}_S$-module.
\end{lemma}

\begin{proof}
Translated into algebra this lemma says the following: If $R \to A$
is a finite ring map, then $R \to A$ is pseudo-coherent as a ring map
(which means by definition that $A$ as an $A$-module is
pseudo-coherent relative to $R$) if and only if
$A$ is pseudo-coherent as an $R$-module. This follows from
the more general
More on Algebra, Lemma
\ref{more-algebra-lemma-finite-extension-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-Noetherian-pseudo-coherent}
Let $f : X \to S$ be a morphism of schemes.
If $S$ is locally Noetherian, then $f$ is pseudo-coherent if
and only if $f$ is locally of finite type.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
If $R \to A$ is a finite type ring map with $R$ Noetherian, then
$R \to A$ is pseudo-coherent if and only if $R \to A$ is of finite type.
To see this, note that a pseudo-coherent ring map is of finite type by
definition. Conversely, if $R \to A$ is of finite type, then
we can write $A = R[x_1, \ldots, x_n]/I$ and it follows from
More on Algebra,
Lemma \ref{more-algebra-lemma-Noetherian-pseudo-coherent}
that $A$ is pseudo-coherent as an $R[x_1, \ldots, x_n]$-module, i.e.,
$R \to A$ is a pseudo-coherent ring map.
\end{proof}

\begin{lemma}
\label{lemma-descending-property-pseudo-coherent}
The property $\mathcal{P}(f) =$``$f$ is pseudo-coherent''
is fpqc local on the base.
\end{lemma}

\begin{proof}
We will use the criterion of
Descent, Lemma \ref{descent-lemma-descending-properties-morphisms}
to prove this. By
Definition \ref{definition-pseudo-coherent}
being pseudo-coherent is Zariski local on the base. By
Lemma \ref{lemma-flat-base-change-pseudo-coherent}
being pseudo-coherent is preserved under flat base change.
The final hypothesis (3) of
Descent, Lemma \ref{descent-lemma-descending-properties-morphisms}
translates into the following algebra statement:
Let $A \to B$ be a faithfully flat ring map.
Let $C = A[x_1, \ldots, x_n]/I$ be an $A$-algebra.
If $C \otimes_A B$ is pseudo-coherent as an $B[x_1, \ldots, x_n]$-module,
then $C$ is pseudo-coherent as a $A[x_1, \ldots, x_n]$-module.
This is
More on Algebra, Lemma \ref{more-algebra-lemma-flat-descent-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-quotient-of-flat-finitely-presented}
Let $A \to B$ be a flat ring map of finite presentation.
Let $I \subset B$ be an ideal. Then $A \to B/I$ is pseudo-coherent
if and only if $I$ is pseudo-coherent as a $B$-module.
\end{lemma}

\begin{proof}
Choose a presentation $B = A[x_1, \ldots, x_n]/J$.
Note that $B$ is pseudo-coherent as an $A[x_1, \ldots, x_n]$-module
because $A \to B$ is a pseudo-coherent ring map by
Lemma \ref{lemma-flat-finite-presentation-pseudo-coherent}.
Note that $A \to B/I$ is pseudo-coherent if and only if
$B/I$ is pseudo-coherent as an $A[x_1, \ldots, x_n]$-module. By
More on Algebra, Lemma \ref{more-algebra-lemma-finite-push-pseudo-coherent}
we see this is equivalent to the condition that $B/I$ is
pseudo-coherent as an $B$-module. This proves the lemma as the
short exact sequence $0 \to I \to B \to B/I \to 0$
shows that $I$ is pseudo-coherent if and only if $B/I$ is (see
More on Algebra,
Lemma \ref{more-algebra-lemma-two-out-of-three-pseudo-coherent}).
\end{proof}

\noindent
The following lemma will be obsoleted by the stronger
Lemma \ref{lemma-pseudo-coherent-fppf-local-source}.

\begin{lemma}
\label{lemma-pseudo-coherent-syntomic-local-source}
The property $\mathcal{P}(f) =$``$f$ is pseudo-coherent''
is syntomic local on the source.
\end{lemma}

\begin{proof}
We will use the criterion of
Descent, Lemma \ref{descent-lemma-properties-morphisms-local-source}
to prove this. It follows from
Lemmas \ref{lemma-flat-finite-presentation-pseudo-coherent} and
\ref{lemma-composition-pseudo-coherent}
that being pseudo-coherent is preserved under precomposing with
flat morphisms locally of finite presentation, in particular under
precomposing with syntomic morphisms (see
Morphisms, Lemmas \ref{morphisms-lemma-syntomic-flat} and
\ref{morphisms-lemma-syntomic-locally-finite-presentation}).
It is clear from
Definition \ref{definition-pseudo-coherent}
that being pseudo-coherent is
Zariski local on the source and target.
Hence, according to the aforementioned
Descent, Lemma \ref{descent-lemma-properties-morphisms-local-source}
it suffices to prove the following: Suppose $X' \to X \to Y$ are
morphisms of affine schemes with $X' \to X$ syntomic and $X' \to Y$
pseudo-coherent. Then $X \to Y$ is pseudo-coherent.
To see this, note that in any case $X \to Y$ is of finite presentation by
Descent, Lemma \ref{descent-lemma-flat-finitely-presented-permanence-algebra}.
Choose a closed immersion $X \to \mathbf{A}^n_Y$. By
Algebra, Lemma \ref{algebra-lemma-lift-syntomic}
we can find an affine open covering $X' = \bigcup_{i = 1, \ldots, n} X'_i$
and syntomic morphisms $W_i \to \mathbf{A}^n_Y$ lifting the morphisms
$X'_i \to X$, i.e., such that there are fibre product diagrams
$$
\xymatrix{
X'_i \ar[d] \ar[r] & W_i \ar[d] \\
X \ar[r] & \mathbf{A}^n_Y
}
$$
After replacing $X'$ by $\coprod X'_i$ and setting $W = \coprod W_i$
we obtain a fibre product diagram
$$
\xymatrix{
X' \ar[d] \ar[r] & W \ar[d]^h \\
X \ar[r] & \mathbf{A}^n_Y
}
$$
with $W \to \mathbf{A}^n_Y$ flat and of finite presentation and
$X' \to Y$ still pseudo-coherent. Since
$W \to \mathbf{A}^n_Y$ is open (see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open})
and $X' \to X$ is surjective we can find
$f \in \Gamma(\mathbf{A}^n_Y, \mathcal{O})$ such that
$X \subset D(f) \subset \Im(h)$. Write
$Y = \Spec(R)$, $X = \Spec(A)$, $X' = \Spec(A')$
and $W = \Spec(B)$, $A = R[x_1, \ldots, x_n]/I$ and
$A' = B/IB$. Then $R \to A'$ is pseudo-coherent. Picture
$$
\xymatrix{
A' = B/IB & B \ar[l] \\
A = R[x_1, \ldots, x_n]/I \ar[u] & R[x_1, \ldots, x_n] \ar[l] \ar[u]
}
$$
By
Lemma \ref{lemma-quotient-of-flat-finitely-presented}
we see that $IB$ is pseudo-coherent as a $B$-module.
The ring map $R[x_1, \ldots, x_n]_f \to B_f$ is faithfully flat by
our choice of $f$ above. This implies that
$I_f \subset R[x_1, \ldots, x_n]_f$
is pseudo-coherent, see
More on Algebra, Lemma \ref{more-algebra-lemma-flat-descent-pseudo-coherent}.
Applying
Lemma \ref{lemma-quotient-of-flat-finitely-presented}
one more time we see that $R \to A$ is pseudo-coherent.
\end{proof}

\begin{lemma}
\label{lemma-pseudo-coherent-fppf-local-source}
The property $\mathcal{P}(f) =$``$f$ is pseudo-coherent''
is fppf local on the source.
\end{lemma}

\begin{proof}
Let $f : X \to S$ be a morphism of schemes.
Let $\{g_i : X_i \to X\}$ be an fppf covering such that each composition
$f \circ g_i$ is pseudo-coherent. According to
Lemma \ref{lemma-dominate-fppf}
there exist
\begin{enumerate}
\item a Zariski open covering $X = \bigcup U_j$,
\item surjective finite locally free morphisms $W_j \to U_j$,
\item Zariski open coverings $W_j = \bigcup_k W_{j, k}$,
\item surjective finite locally free morphisms $T_{j, k} \to W_{j, k}$
\end{enumerate}
such that the fppf covering $\{h_{j, k} : T_{j, k} \to X\}$ refines the given
covering $\{X_i \to X\}$. Denote $\psi_{j, k} : T_{j, k} \to X_{\alpha(j, k)}$
the morphisms that witness the fact that $\{T_{j, k} \to X\}$ refines
the given covering $\{X_i \to X\}$. Note that $T_{j, k} \to X$ is a flat,
locally finitely presented morphism, so both $X_i$ and $T_{j, k}$ are
pseudo-coherent over $X$ by
Lemma \ref{lemma-flat-finite-presentation-pseudo-coherent}.
Hence $\psi_{j, k} : T_{j, k} \to X_i$ is pseudo-coherent, see
Lemma \ref{lemma-permanence-pseudo-coherent}.
Hence $T_{j, k} \to S$ is pseudo coherent as the composition
of $\psi_{j, k}$ and $f \circ g_{\alpha(j, k)}$, see
Lemma \ref{lemma-composition-pseudo-coherent}.
Thus we see we have reduced the lemma to the case of
a Zariski open covering (which is OK) and the case of a covering
given by a single surjective finite locally free morphism which we
deal with in the following paragraph.

\medskip\noindent
Assume that $X' \to X \to S$ is a sequence of morphisms of schemes
with $X' \to X$ surjective finite locally free and $X' \to Y$ pseudo-coherent.
Our goal is to show that $X \to S$ is pseudo-coherent.
Note that by
Descent, Lemma \ref{descent-lemma-flat-finitely-presented-permanence}
the morphism $X \to S$ is locally of finite presentation.
It is clear that the problem reduces to the case that $X'$, $X$ and $S$
are affine and $X' \to X$ is free of some rank $r > 0$. The corresponding
algebra problem is the following: Suppose $R \to A \to A'$ are ring maps
such that $R \to A'$ is pseudo-coherent, $R \to A$ is of finite presentation,
and $A' \cong A^{\oplus r}$ as an $A$-module. Goal: Show $R \to A$ is
pseudo-coherent. The assumption that $R \to A'$ is pseudo-coherent
means that $A'$ as an $A'$-module is pseudo-coherent relative to $R$. By
More on Algebra,
Lemma \ref{more-algebra-lemma-finite-extension-pseudo-coherent}
this implies that $A'$ as an $A$-module is pseudo-coherent relative to $R$.
Since $A' \cong A^{\oplus r}$ as an $A$-module we see that
$A$ as an $A$-module is pseudo-coherent relative to $R$, see
More on Algebra,
Lemma \ref{more-algebra-lemma-summands-relative-pseudo-coherent}.
This by definition means that $R \to A$ is pseudo-coherent and we win.
\end{proof}








\section{Perfect morphisms}
\label{section-perfect}

\noindent
In order to understand the material in this
section you have to understand the material of the section
on pseudo-coherent morphisms just a little bit.
For now the only thing you need to know is that a ring map
$A \to B$ is perfect if and only if it is pseudo-coherent
and $B$ has finite tor dimension as an $A$-module.

\begin{lemma}
\label{lemma-perfect}
Let $f : X \to S$ be a morphism of schemes which is locally of finite type.
The following are equivalent
\begin{enumerate}
\item there exist an affine open covering $S = \bigcup V_j$ and for each $j$
an affine open covering $f^{-1}(V_j) = \bigcup U_{ji}$ such that
$\mathcal{O}_S(V_j) \to \mathcal{O}_X(U_{ij})$ is a perfect
ring map, and
\item for every pair of affine opens $U \subset X$, $V \subset S$
such that $f(U) \subset V$ the ring map
$\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is perfect.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1) and let $U, V$ be as in (2).
It follows from
Lemma \ref{lemma-pseudo-coherent}
that $\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is pseudo-coherent.
Hence it suffices to prove that the property of a ring map
being "of finite tor dimension" satisfies
conditions (1)(a), (b), (c) of
Morphisms, Definition \ref{morphisms-definition-property-local}.
These properties follow from
More on Algebra,
Lemmas \ref{more-algebra-lemma-flat-push-tor-amplitude},
\ref{more-algebra-lemma-flat-base-change-finite-tor-dimension}, and
\ref{more-algebra-lemma-glue-tor-amplitude}.
Some details omitted.
\end{proof}

\begin{definition}
\label{definition-perfect}
A morphism of schemes $f : X \to S$ is called {\it perfect}
if the equivalent conditions of
Lemma \ref{lemma-perfect}
are satisfied. In this case we also say that $X$ is perfect
over $S$.
\end{definition}

\noindent
Note that a perfect morphism is in particular pseudo-coherent, hence
locally of finite presentation. Beware that a base change of a perfect
morphism is not perfect in general.

\begin{lemma}
\label{lemma-flat-base-change-perfect}
A flat base change of a perfect morphism is perfect.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
Let $A \to B$ be a perfect ring map.
Let $A \to A'$ be flat. Then $A' \to B \otimes_A A'$ is
perfect. This result for pseudo-coherent ring maps we have seen in
Lemma \ref{lemma-flat-base-change-pseudo-coherent}.
The corresponding fact for finite tor dimension follows from
More on Algebra,
Lemma \ref{more-algebra-lemma-flat-base-change-finite-tor-dimension}.
\end{proof}

\begin{lemma}
\label{lemma-composition-perfect}
A composition of perfect morphisms of schemes is perfect.
\end{lemma}

\begin{proof}
This translates into the following algebra result:
If $A \to B \to C$ are composable perfect ring maps
then $A \to C$ is perfect. We have seen this is the case for
pseudo-coherent in
Lemma \ref{lemma-composition-pseudo-coherent}
and its proof. By assumption there exist integers $n$, $m$ such
that $B$ has tor dimension $\leq n$ over $A$ and $C$ has tor dimension
$\leq m$ over $B$. Then for any $A$-module $M$ we have
$$
M \otimes_A^{\mathbf{L}} C =
(M \otimes_A^{\mathbf{L}} B) \otimes_B^{\mathbf{L}} C
$$
and the spectral sequence of
More on Algebra, Example \ref{more-algebra-example-tor}
shows that $\text{Tor}^A_p(M, C) = 0$ for $p > n + m$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-flat-finite-presentation-perfect}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is flat and perfect, and
\item $f$ is flat and locally of finite presentation.
\end{enumerate}
\end{lemma}

\begin{proof}
The implication (2) $\Rightarrow$ (1) is
More on Algebra,
Lemma \ref{more-algebra-lemma-flat-finite-presentation-perfect}.
The converse follows from the fact that a pseudo-coherent morphism
is locally of finite presentation, see
Lemma \ref{lemma-pseudo-coherent-finite-presentation}.
\end{proof}

\begin{lemma}
\label{lemma-regular-target-perfect}
Let $f : X \to S$ be a morphism of schemes.
Assume $S$ is regular and $f$ is locally of finite type.
Then $f$ is perfect.
\end{lemma}

\begin{proof}
See
More on Algebra, Lemma \ref{more-algebra-lemma-regular-perfect-ring-map}.
\end{proof}

\begin{lemma}
\label{lemma-regular-immersion-perfect}
A regular immersion of schemes is perfect.
A Koszul-regular immersion of schemes is perfect.
\end{lemma}

\begin{proof}
Since a regular immersion is a Koszul-regular immersion, see
Divisors, Lemma \ref{divisors-lemma-regular-quasi-regular-immersion},
it suffices to prove the second statement. This translates into the
following algebraic statement: Suppose that $I \subset A$ is an
ideal generated by a Koszul-regular sequence $f_1, \ldots, f_r$ of $A$.
Then $A \to A/I$ is a perfect ring map. Since $A \to A/I$ is surjective
this is a presentation of $A/I$ by a polynomial algebra over $A$.
Hence it suffices to see that $A/I$ is pseudo-coherent as an $A$-module
and has finite tor dimension. By definition of a Koszul sequence
the Koszul complex $K(A, f_1, \ldots, f_r)$ is a finite free resolution
of $A/I$. Hence $A/I$ is a perfect complex of $A$-modules and we win.
\end{proof}

\begin{lemma}
\label{lemma-perfect-permanence}
Let
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
be a commutative diagram of morphisms of schemes. Assume $Y \to S$
smooth and $X \to S$ perfect. Then $f : X \to Y$ is perfect.
\end{lemma}

\begin{proof}
We can factor $f$ as the composition
$$
X \longrightarrow X \times_S Y \longrightarrow Y
$$
where the first morphism is the map $i = (1, f)$ and the second
morphism is the projection. Since $Y \to S$ is flat, see
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat},
we see that $X \times_S Y \to Y$ is perfect by
Lemma \ref{lemma-flat-base-change-perfect}.
As $Y \to S$ is smooth, also $X \times_S Y \to X$ is smooth, see
Morphisms, Lemma \ref{morphisms-lemma-base-change-smooth}.
Hence $i$ is a section of a smooth morphism, therefore $i$ is
a regular immersion, see
Divisors, Lemma \ref{divisors-lemma-section-smooth-regular-immersion}.
This implies that $i$ is perfect, see
Lemma \ref{lemma-regular-immersion-perfect}.
We conclude that $f$ is perfect because the composition of perfect
morphisms is perfect, see
Lemma \ref{lemma-composition-perfect}.
\end{proof}

\begin{remark}
\label{remark-perfect-permanence}
It is not true that a morphism between schemes $X, Y$ perfect over a base $S$
is perfect. An example is $S = \Spec(k)$, $X = \Spec(k)$,
$Y = \Spec(k[x]/(x^2)$ and $X \to Y$ the unique $S$-morphism.
\end{remark}

\begin{lemma}
\label{lemma-descending-property-perfect}
The property $\mathcal{P}(f) =$``$f$ is perfect''
is fpqc local on the base.
\end{lemma}

\begin{proof}
We will use the criterion of
Descent, Lemma \ref{descent-lemma-descending-properties-morphisms}
to prove this. By
Definition \ref{definition-perfect}
being perfect is Zariski local on the base. By
Lemma \ref{lemma-flat-base-change-perfect}
being perfect is preserved under flat base change.
The final hypothesis (3) of
Descent, Lemma \ref{descent-lemma-descending-properties-morphisms}
translates into the following algebra statement:
Let $A \to B$ be a faithfully flat ring map.
Let $C = A[x_1, \ldots, x_n]/I$ be an $A$-algebra.
If $C \otimes_A B$ is perfect as an $B[x_1, \ldots, x_n]$-module,
then $C$ is perfect as a $A[x_1, \ldots, x_n]$-module.
This is
More on Algebra, Lemma \ref{more-algebra-lemma-flat-descent-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-check-perfect-stalks}
Let $f : X \to S$ be a pseudo-coherent morphism of schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is perfect,
\item $\mathcal{O}_X$ locally has finite tor dimension as a
sheaf of $f^{-1}\mathcal{O}_S$-modules, and
\item for all $x \in X$ the ring $\mathcal{O}_{X, x}$ has finite tor
dimension as an $\mathcal{O}_{S, f(x)}$-module.
\end{enumerate}
\end{lemma}

\begin{proof}
The problem is local on $X$ and $S$. Hence we may assume that
$X = \Spec(B)$, $S = \Spec(A)$ and $f$ corresponds to a pseudo-coherent
ring map $A \to B$.

\medskip\noindent
If (1) holds, then $B$ has finite tor dimension $d$ as $A$-module. Then
$B_\mathfrak q$ has tor dimension $d$ as an $A_\mathfrak p$-module for all
primes $\mathfrak q \subset B$ with $\mathfrak p = A \cap \mathfrak q$, see
More on Algebra, Lemma \ref{more-algebra-lemma-tor-amplitude-localization}.
Then $\mathcal{O}_X$ has tor dimension $d$ as a 
sheaf of $f^{-1}\mathcal{O}_S$-modules by
Cohomology, Lemma \ref{cohomology-lemma-tor-amplitude-stalk}.
Thus (1) implies (2).

\medskip\noindent
By Cohomology, Lemma \ref{cohomology-lemma-tor-amplitude-stalk} (2) implies
(3).

\medskip\noindent
Assume (3). We cannot use
More on Algebra, Lemma \ref{more-algebra-lemma-tor-amplitude-localization}
to conclude as we are not given that the tor dimension of
$B_\mathfrak q$ over $A_\mathfrak p$ is bounded independent of $\mathfrak q$.
Choose a presentation $A[x_1, \ldots, x_n] \to B$. Then $B$ is
pseudo-coherent as a $A[x_1, \ldots, x_n]$-module. Let
$\mathfrak q \subset A[x_1, \ldots, x_n]$ be a prime ideal
lying over $\mathfrak p \subset A$. Then either $B_\mathfrak q$ is zero
or by assumption it has finite tor dimension as an
$A_\mathfrak p$-module. Since the fibres of $A \to A[x_1, \ldots, x_n]$
have finite global dimension, we can apply
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-over-polynomial-ring}
to $A_\mathfrak p \to A[x_1, \ldots, x_n]_\mathfrak q$
to see that $B_\mathfrak q$ is a perfect
$A[x_1, \ldots, x_n]_\mathfrak q$-module. Hence
$B$ is a perfect $A[x_1, \ldots, x_n]$-module by
More on Algebra, Lemma \ref{more-algebra-lemma-check-perfect-stalks}.
Thus $A \to B$ is a perfect ring map by definition.
\end{proof}

\begin{lemma}
\label{lemma-perfect-closed-immersion-perfect-direct-image}
Let $i : Z \to X$ be a perfect closed immersion of schemes.
Then $i_*\mathcal{O}_Z$ is a perfect $\mathcal{O}_X$-module, i.e.,
it is a perfect object of $D(\mathcal{O}_X)$.
\end{lemma}

\begin{proof}
This is more or less immediate from the definition. Namely, let
$U = \Spec(A)$ be an affine open of $X$. Then $i^{-1}(U) = \Spec(A/I)$
for some ideal $I \subset A$ and $A/I$ has a finite resolution by
finite projective $A$-modules by
More on Algebra, Lemma \ref{more-algebra-lemma-perfect-ring-map}.
Hence $i_*\mathcal{O}_Z|_U$ can be represented by a finite
length complex of finite locally free $\mathcal{O}_U$-modules.
This is what we had to show, see
Cohomology, Section \ref{cohomology-section-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-proper-perfect-direct-image}
Let $S$ be a Noetherian scheme. Let $f : X \to S$ be a perfect proper
morphism of schemes. Let $E \in D(\mathcal{O}_X)$ be perfect. Then
$Rf_*E$ is a perfect object of $D(\mathcal{O}_S)$.
\end{lemma}

\begin{proof}
We claim that Derived Categories of Schemes, Lemma
\ref{perfect-lemma-perfect-direct-image} applies.
Conditions (1) and (2) are immediate. Condition (3) is local
on $X$. Thus we may assume $X$ and $S$ affine and $E$
represented by a strictly perfect complex of $\mathcal{O}_X$-modules.
Thus it suffices to show that $\mathcal{O}_X$ has finite
tor dimension as a sheaf of $f^{-1}\mathcal{O}_S$-modules.
This is equivalent to being perfect by
Lemma \ref{lemma-check-perfect-stalks}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-fppf-local-source}
The property $\mathcal{P}(f) =$``$f$ is perfect''
is fppf local on the source.
\end{lemma}

\begin{proof}
Let $\{g_i : X_i \to X\}_{i \in I}$ be an fppf covering of schemes and let
$f : X \to S$ be a morphism such that each $f \circ g_i$ is
perfect. By
Lemma \ref{lemma-pseudo-coherent-fppf-local-source}
we conclude that $f$ is pseudo-coherent.
Hence by
Lemma \ref{lemma-check-perfect-stalks}
it suffices to check that $\mathcal{O}_{X, x}$ is an
$\mathcal{O}_{S, f(x)}$-module of finite tor dimension for all $x \in X$.
Pick $i \in I$ and $x_i \in X_i$ mapping to $x$. Then we see that
$\mathcal{O}_{X_i, x_i}$ has finite tor dimension over
$\mathcal{O}_{S, f(x)}$ and that
$\mathcal{O}_{X, x} \to \mathcal{O}_{X_i, x_i}$ is faithfully flat.
The desired conclusion follows from
More on Algebra, Lemma \ref{more-algebra-lemma-flat-descent-tor-amplitude}.
\end{proof}

\begin{lemma}
\label{lemma-factor-regular-immersion}
Let $i : Z \to Y$ and $j : Y \to X$ be immersions of schemes.
Assume
\begin{enumerate}
\item $X$ is locally Noetherian,
\item $j \circ i$ is a regular immersion, and
\item $i$ is perfect.
\end{enumerate}
Then $i$ and $j$ are regular immersions.
\end{lemma}

\begin{proof}
Since $X$ (and hence $Y$) is locally Noetherian all 4 types of regular
immersions agree, and moreover we may check whether a morphism is a
regular immersion on the level of local rings, see
Divisors, Lemma \ref{divisors-lemma-Noetherian-scheme-regular-ideal}.
Thus the result follows from
Divided Power Algebra, Lemma \ref{dpa-lemma-regular-sequence}.
\end{proof}









\section{Local complete intersection morphisms}
\label{section-lci}

\noindent
In
Divisors, Section \ref{divisors-section-regular-immersions}
we have defined 4 different types of regular immersions: regular,
Koszul-regular, $H_1$-regular, and quasi-regular. In this section
we consider morphisms $f : X \to S$ which locally on $X$ factor as
$$
\xymatrix{
X \ar[rr]_i \ar[rd] & & \mathbf{A}^n_S \ar[ld] \\
& S
}
$$
where $i$ is a $*$-regular immersion for
$* \in \{\emptyset, Koszul, H_1, quasi\}$.
However, we don't know how to prove that this condition is independent
of the factorization if $* = \emptyset$, i.e., when we require $i$ to
be a regular immersion. On the other hand, we want a
local complete intersection morphism to be perfect, which is only
going to be true if $* = Koszul$ or $* = \emptyset$. Hence we will define a
{\it local complete intersection morphism} or
{\it Koszul morphism} to be a morphism of schemes $f : X \to S$
that locally on $X$ has a factorization as above with $i$ a Koszul-regular
immersion. To see that this works we first prove this is independent
of the chosen factorizations.

\begin{lemma}
\label{lemma-koszul-independence-factorization}
Let $S$ be a scheme. Let $U$, $P$, $P'$ be schemes over $S$.
Let $u \in U$. Let $i : U \to P$, $i' : U \to P'$ be immersions over $S$.
Assume $P$ and $P'$ smooth over $S$. Then the following are equivalent
\begin{enumerate}
\item $i$ is a Koszul-regular immersion in a neighbourhood of $x$, and
\item $i'$ is a Koszul-regular immersion in a neighbourhood of $x$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $i$ is a Koszul-regular immersion in a neighbourhood of $x$.
Consider the morphism $j = (i, i') : U \to P \times_S P' = P''$.
Since $P'' = P \times_S P' \to P$ is smooth, it follows from
Divisors, Lemma \ref{divisors-lemma-lift-regular-immersion-to-smooth}
that $j$ is a Koszul-regular immersion, whereupon it follows from
Divisors, Lemma \ref{divisors-lemma-push-regular-immersion-thru-smooth}
that $i'$ is a Koszul-regular immersion.
\end{proof}

\noindent
Before we state the definition, let us make the following simple
remark. Let $f : X \to S$ be a morphism of schemes which is locally
of finite type. Let $x \in X$. Then there exist an open neighbourhood
$U \subset X$ and a factorization of $f|_U$ as the composition of an
immersion $i : U \to \mathbf{A}^n_S$ followed by the projection
$\mathbf{A}^n_S \to S$ which is smooth. Picture
$$
\xymatrix{
X \ar[rd] & U \ar[l] \ar[d] \ar[r]_-i & \mathbf{A}^n_S = P \ar[ld]^\pi \\
& S
}
$$
In fact you can do this with any affine open neighbourhood
$U$ of $x$ in $X$, see
Morphisms, Lemma \ref{morphisms-lemma-quasi-affine-finite-type-over-S}.

\begin{definition}
\label{definition-lci}
Let $f : X \to S$ be a morphism of schemes.
\begin{enumerate}
\item Let $x \in X$. We say that $f$ is {\it Koszul at $x$} if $f$
is of finite type at $x$ and there exists an open neighbourhood
and a factorization of $f|_U$ as $\pi \circ i$ where $i : U \to P$
is a Koszul-regular immersion and $\pi : P \to S$ is smooth.
\item We say $f$ is a {\it Koszul morphism}, or that
$f$ is a {\it local complete intersection morphism}
if $f$ is Koszul at every point.
\end{enumerate}
\end{definition}

\noindent
We have seen above that the choice of the factorization
$f|_U = \pi \circ i$ is irrelevant, i.e., given a factorization
of $f|_U$ as an immersion $i$ followed by a smooth morphism $\pi$, whether or
not $i$ is Koszul regular in a neighbourhood of $x$ is an intrinsic
property of $f$ at $x$. Let us record this here explicitly as a lemma
so that we can refer to it

\begin{lemma}
\label{lemma-lci}
Let $f : X \to S$ be a local complete intersection morphism.
Let $P$ be a scheme smooth over $S$. Let $U \subset X$ be an open subscheme
and $i : U \to P$ an immersion of schemes over $S$.
Then $i$ is a Koszul-regular immersion.
\end{lemma}

\begin{proof}
This is the defining property of a local complete intersection
morphism. See discussion above.
\end{proof}

\noindent
It seems like a good idea to collect here some properties in common
with all Koszul morphisms.

\begin{lemma}
\label{lemma-lci-properties}
Let $f : X \to S$ be a local complete intersection morphism.
Then
\begin{enumerate}
\item $f$ is locally of finite presentation,
\item $f$ is pseudo-coherent, and
\item $f$ is perfect.
\end{enumerate}
\end{lemma}

\begin{proof}
Since a perfect morphism is pseudo-coherent
(because a perfect ring map is pseudo-coherent)
and a pseudo-coherent morphism is locally of finite presentation
(because a pseudo-coherent ring map is of finite presentation)
it suffices to prove the last statement. Being perfect is a local
property, hence we may assume that $f$ factors as $\pi \circ i$ where
$\pi$ is smooth and $i$ is a Koszul-regular immersion.
A Koszul-regular immersion is perfect, see
Lemma \ref{lemma-regular-immersion-perfect}.
A smooth morphism is perfect as it is flat and locally of finite
presentation, see
Lemma \ref{lemma-flat-finite-presentation-perfect}.
Finally a composition of perfect morphisms is perfect, see
Lemma \ref{lemma-composition-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-affine-lci}
Let $f : X = \Spec(B) \to S = \Spec(A)$ be a morphism of affine schemes.
Then $f$ is a local complete intersection morphism if and only if
$A \to B$ is a local complete intersection homomorphism, see
More on Algebra, Definition
\ref{more-algebra-definition-local-complete-intersection}.
\end{lemma}

\begin{proof}
Follows immediately from the definitions.
\end{proof}

\noindent
Beware that a base change of a Koszul morphism is not
Koszul in general.

\begin{lemma}
\label{lemma-flat-base-change-lci}
A flat base change of a local complete intersection morphism is a
local complete intersection morphism.
\end{lemma}

\begin{proof}
Omitted. Hint: This is true because a base change of a smooth morphism
is smooth and a flat base change of a Koszul-regular immersion is a
Koszul-regular immersion, see
Divisors, Lemma \ref{divisors-lemma-regular-immersion-noetherian}.
\end{proof}

\begin{lemma}
\label{lemma-composition-lci}
A composition of local complete intersection morphisms
is a local complete intersection morphism.
\end{lemma}

\begin{proof}
Let $g : Y \to S$ and $f : X \to Y$ be local complete intersection
morphisms. Let $x \in X$ and set $y = f(x)$. Choose an open neighbourhood
$V \subset Y$ of $y$ and a factorization $g|_V = \pi \circ i$ for some
Koszul-regular immersion $i : V \to P$ and smooth morphism $\pi : P \to S$.
Next choose an open neighbourhood $U$ of $x \in X$ and a factorization
$f|_U = \pi' \circ i'$ for some Koszul-regular immersion $i' : U \to P'$
and smooth morphism $\pi' : P' \to Y$. In fact, we may assume that
$P' = \mathbf{A}^n_V$, see discussion preceding and following
Definition \ref{definition-lci}. Picture:
$$
\xymatrix{
X \ar[d] & U \ar[l] \ar[r]_-{i'} & P' = \mathbf{A}^n_V \ar[d] \\
Y \ar[d] &  & V \ar[ll] \ar[r]_i & P \ar[d] \\
S & & & S \ar[lll]
}
$$
Set $P'' = \mathbf{A}^n_P$. Then $U \to P' \to P''$ is a
Koszul-regular immersion as a composition
of Koszul-regular immersions, namely $i'$ and the flat base change of
$i$ via $P'' \to P$, see
Divisors,
Lemma \ref{divisors-lemma-regular-immersion-noetherian}
and
Divisors, Lemma \ref{divisors-lemma-composition-regular-immersion}.
Also $P'' \to P \to S$ is smooth as a composition of smooth morphisms,
see
Morphisms, Lemma \ref{morphisms-lemma-composition-smooth}.
Hence we conclude that $X \to S$ is Koszul at $x$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-flat-lci}
\begin{slogan}
A morphism is flat and lci if and only if it is syntomic.
\end{slogan}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is flat and a local complete intersection morphism, and
\item $f$ is syntomic.
\end{enumerate}
\end{lemma}

\begin{proof}
Working affine locally this is
More on Algebra, Lemma \ref{more-algebra-lemma-syntomic-lci}.
We also give a more geometric proof.

\medskip\noindent
Assume (2). By
Morphisms, Lemma \ref{morphisms-lemma-syntomic-locally-standard-syntomic}
for every point $x$ of $X$ there exist affine open neighbourhoods
$U$ of $x$ and $V$ of $f(x)$ such that $f|_U : U \to V$ is standard syntomic.
This means that $U = \Spec(R[x_1, \ldots, x_n]/(f_1, \ldots, f_c))
\to V = \Spec(R)$ where $R[x_1, \ldots, x_n]/(f_1, \ldots, f_c)$ is a
relative global complete intersection over $R$. By
Algebra,
Lemma \ref{algebra-lemma-relative-global-complete-intersection-conormal}
the sequence $f_1, \ldots, f_c$ is a regular sequence in each local
ring $R[x_1, \ldots, x_n]_{\mathfrak q}$ for every prime
$\mathfrak q \supset (f_1, \ldots, f_c)$. Consider the Koszul complex
$K_\bullet = K_\bullet(R[x_1, \ldots, x_n], f_1, \ldots, f_c)$
with homology groups $H_i = H_i(K_\bullet)$. By
More on Algebra, Lemma \ref{more-algebra-lemma-regular-koszul-regular}
we see that $(H_i)_{\mathfrak q} = 0$, $i > 0$ for every $\mathfrak q$
as above. On the other hand, by
More on Algebra, Lemma \ref{more-algebra-lemma-homotopy-koszul}
we see that $H_i$ is annihilated by $(f_1, \ldots, f_c)$. Hence we
see that $H_i = 0$, $i > 0$ and $f_1, \ldots, f_c$ is a Koszul-regular
sequence. This proves that $U \to V$ factors as a Koszul-regular
immersion $U \to \mathbf{A}^n_V$ followed by a smooth morphism as desired.

\medskip\noindent
Assume (1). Then $f$ is a flat and locally of finite presentation
(Lemma \ref{lemma-lci-properties}).
Hence, according to
Morphisms, Lemma \ref{morphisms-lemma-syntomic-locally-standard-syntomic}
it suffices to show that the local rings $\mathcal{O}_{X_s, x}$
are local complete intersection rings. Choose, locally on $X$, a factorization
$f = \pi \circ i$ for some Koszul-regular immersion $i : X \to P$
and smooth morphism $\pi : P \to S$. Note that $X \to P$ is
a relative quasi-regular immersion over $S$, see
Divisors, Definition \ref{divisors-definition-relative-H1-regular-immersion}.
Hence according to
Divisors,
Lemma \ref{divisors-lemma-relative-regular-immersion-flat-in-neighbourhood}
we see that $X \to P$ is a regular immersion and the same remains true
after any base change. Thus each fibre is a regular immersion, whence
all the local rings of all the fibres of $X$ are local complete intersections.
\end{proof}

\begin{lemma}
\label{lemma-regular-immersion-lci}
A regular immersion of schemes is a local complete intersection morphism.
A Koszul-regular immersion of schemes is a local complete intersection
morphism.
\end{lemma}

\begin{proof}
Since a regular immersion is a Koszul-regular immersion, see
Divisors, Lemma \ref{divisors-lemma-regular-quasi-regular-immersion},
it suffices to prove the second statement. The second statement
follows immediately from the definition.
\end{proof}

\begin{lemma}
\label{lemma-lci-permanence}
Let
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
be a commutative diagram of morphisms of schemes. Assume $Y \to S$
smooth and $X \to S$ is a local complete intersection morphism.
Then $f : X \to Y$ is a local complete intersection morphism.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-morphism-regular-schemes-is-lci}
Let $f : X \to Y$ be a morphism of schemes. If $f$ is locally
of finite type and $X$ and $Y$ are regular, then
$f$ is a local complete intersection morphism.
\end{lemma}

\begin{proof}
We may assume there is a factorization $X \to \mathbf{A}^n_Y \to Y$
where the first arrow is an immersion.
As $Y$ is regular also $\mathbf{A}^n_Y$ is regular by
Algebra, Lemma \ref{algebra-lemma-regular-goes-up}.
Hence $X \to \mathbf{A}^n_Y$ is a regular immersion by
Divisors, Lemma \ref{divisors-lemma-immersion-regular-regular-immersion}.
\end{proof}

\noindent
The following lemma is of a different nature.

\begin{lemma}
\label{lemma-lci-avramov}
Let
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
be a commutative diagram of morphisms of schemes. Assume
\begin{enumerate}
\item $S$ is locally Noetherian,
\item $Y \to S$ is locally of finite type,
\item $f : X \to Y$ is perfect,
\item $X \to S$ is a local complete intersection morphism.
\end{enumerate}
Then $X \to Y$ is a local complete intersection morphism
and $Y \to S$ is Koszul at $f(x)$ for all $x \in X$.
\end{lemma}

\begin{proof}
In the course of this proof all schemes will be locally Noetherian
and all rings will be Noetherian. We will use without further mention
that regular sequences and Koszul regular sequences agree in this
setting, see More on Algebra, Lemma
\ref{more-algebra-lemma-noetherian-finite-all-equivalent}.
Moreover, whether an ideal (resp.\ ideal sheaf) is regular
may be checked on local rings (resp.\ stalks), see
Algebra, Lemma \ref{algebra-lemma-regular-sequence-in-neighbourhood}
(resp.\ Divisors, Lemma \ref{divisors-lemma-Noetherian-scheme-regular-ideal})

\medskip\noindent
The question is local. Hence we may assume $S$, $X$, $Y$ are
affine. In this situation we may choose a commutative diagram
$$
\xymatrix{
\mathbf{A}^{n + m}_S \ar[d] & X \ar[l] \ar[d] \\
\mathbf{A}^n_S \ar[d] & Y \ar[l] \ar[ld] \\
S
}
$$
whose horizontal arrows are closed immersions. Let $x \in X$ be a
point and consider the corresponding commutative diagram of local
rings
$$
\xymatrix{
J \ar[r] &
\mathcal{O}_{\mathbf{A}^{n + m}_S, x} \ar[r] &
\mathcal{O}_{X, x} \\
I \ar[r] \ar[u] &
\mathcal{O}_{\mathbf{A}^n_S, f(x)} \ar[r] \ar[u] &
\mathcal{O}_{Y, f(x)} \ar[u]
}
$$
where $J$ and $I$ are the kernels of the horizontal arrows.
Since $X \to S$ is a local complete intersection morphism, the
ideal $J$ is generated by a regular sequence. Since $X \to Y$ is
perfect the ring $\mathcal{O}_{X, x}$ has finite tor dimension over
$\mathcal{O}_{Y, f(x)}$. Hence we may apply
Divided Power Algebra, Lemma \ref{dpa-lemma-perfect-map-ci}
to conclude that $I$ and $J/I$ are generated by regular sequences.
By our initial remarks, this finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-lci-to-regular}
Let
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
be a commutative diagram of morphisms of schemes. Assume
$S$ is locally Noetherian, $Y \to S$ is locally of finite type,
$Y$ is regular, and $X \to S$ is a local complete intersection morphism.
Then $f : X \to Y$ is a local complete intersection morphism
and $Y \to S$ is Koszul at $f(x)$ for all $x \in X$.
\end{lemma}

\begin{proof}
This is a special case of Lemma \ref{lemma-lci-avramov}
in view of Lemma \ref{lemma-regular-target-perfect}
(and Morphisms, Lemma \ref{morphisms-lemma-permanence-finite-type}).
\end{proof}

\begin{lemma}
\label{lemma-perfect-conormal-free-lci}
Let $i : X \to Y$ be an immersion. If
\begin{enumerate}
\item $i$ is perfect,
\item $Y$ is locally Noetherian, and
\item the conormal sheaf $\mathcal{C}_{X/Y}$ is finite locally free,
\end{enumerate}
then $i$ is a regular immersion.
\end{lemma}

\begin{proof}
Translated into algebra, this is
Divided Power Algebra, Proposition \ref{dpa-proposition-regular-ideal}.
\end{proof}

\begin{lemma}
\label{lemma-lci-NL}
Let $f : X \to Y$ be a local complete intersection homomorphism.
Then the naive cotangent complex $\NL_{X/Y}$ is a perfect object
of $D(\mathcal{O}_X)$ of tor-amplitude in $[-1, 0]$.
\end{lemma}

\begin{proof}
Translated into algebra this is
More on Algebra, Lemma \ref{more-algebra-lemma-lci-NL}.
To do the translation use
Lemmas \ref{lemma-affine-lci} and
\ref{lemma-NL-affine} as well as
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded},
\ref{perfect-lemma-tor-dimension-affine} and
\ref{perfect-lemma-perfect-affine}.
\end{proof}

\begin{lemma}
\label{lemma-perfect-NL-lci}
Let $f : X \to Y$ be a perfect morphism of locally Noetherian schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is a local complete intersection morphism,
\item $\NL_{X/Y}$ has tor-amplitude in $[-1, 0]$, and
\item $\NL_{X/Y}$ is perfect with tor-amplitude in $[-1, 0]$.
\end{enumerate}
\end{lemma}

\begin{proof}
Translated into algebra this is
Divided Power Algebra, Lemma \ref{dpa-lemma-perfect-NL-lci}.
To do the translation use
Lemmas \ref{lemma-affine-lci} and
\ref{lemma-NL-affine} as well as
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded},
\ref{perfect-lemma-tor-dimension-affine} and
\ref{perfect-lemma-perfect-affine}.
\end{proof}

\begin{lemma}
\label{lemma-flat-fp-NL-lci}
Let $f : X \to Y$ be a flat morphism of finite presentation.
The following are equivalent
\begin{enumerate}
\item $f$ is a local complete intersection morphism,
\item $f$ is syntomic,
\item $\NL_{X/Y}$ has tor-amplitude in $[-1, 0]$, and
\item $\NL_{X/Y}$ is perfect with tor-amplitude in $[-1, 0]$.
\end{enumerate}
\end{lemma}

\begin{proof}
Translated into algebra this is
Divided Power Algebra, Lemma \ref{dpa-lemma-flat-fp-NL-lci}.
To do the translation use
Lemmas \ref{lemma-affine-lci} and
\ref{lemma-NL-affine} as well as
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-affine-compare-bounded},
\ref{perfect-lemma-tor-dimension-affine} and
\ref{perfect-lemma-perfect-affine}.
\end{proof}

\noindent
The following lemma gives a characterization of smooth morphisms as flat
morphisms whose diagonal is perfect.

\begin{lemma}
\label{lemma-smooth-diagonal-perfect}
Let $f : X \to Y$ be a finite type morphism of locally Noetherian schemes.
Denote $\Delta : X \to X \times_Y X$ the diagonal morphism.
The following are equivalent
\begin{enumerate}
\item $f$ is smooth,
\item $f$ is flat and $\Delta : X \to X \times_Y X$ is a regular immersion,
\item $f$ is flat and $\Delta : X \to X \times_Y X$ is a
local complete intersection morphism,
\item $f$ is flat and $\Delta : X \to X \times_Y X$ is perfect.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1). Then $f$ is flat by
Morphisms, Lemma \ref{morphisms-lemma-smooth-flat}.
The projections $X \times_Y X \to X$ are smooth by
Morphisms, Lemma \ref{morphisms-lemma-base-change-smooth}. Hence the diagonal
is a section to a smooth morphism and hence a regular immersion, see
Divisors, Lemma \ref{divisors-lemma-section-smooth-regular-immersion}.
Hence (1) $\Rightarrow$ (2).
The implication (2) $\Rightarrow$ (3) is
Lemma \ref{lemma-regular-immersion-lci}.
The implication (3) $\Rightarrow$ (4) is
Lemma \ref{lemma-lci-properties}.
The interesting implication (4) $\Rightarrow$ (1) follows immediately
from Divided Power Algebra, Lemma \ref{dpa-lemma-perfect-diagonal}.
\end{proof}

\begin{lemma}
\label{lemma-descending-property-lci}
The property $\mathcal{P}(f) =$``$f$ is a local complete intersection
morphism'' is fpqc local on the base.
\end{lemma}

\begin{proof}
Let $f : X \to S$ be a morphism of schemes.
Let $\{S_i \to S\}$ be an fpqc covering of $S$.
Assume that each base change $f_i : X_i \to S_i$ of $f$ is
a local complete intersection morphism.
Note that this implies in particular that $f$ is locally of finite
type, see
Lemma \ref{lemma-lci-properties}
and
Descent, Lemma \ref{descent-lemma-descending-property-locally-finite-type}.
Let $x \in X$. Choose an open neighbourhood $U$ of $x$ and
an immersion $j : U \to \mathbf{A}^n_S$ over $S$ (see
discussion preceding
Definition \ref{definition-lci}).
We have to show that $j$ is a Koszul-regular immersion.
Since $f_i$ is a local complete intersection morphism, we see
that the base change $j_i : U \times_S S_i \to \mathbf{A}^n_{S_i}$
is a Koszul-regular immersion, see
Lemma \ref{lemma-lci}.
Because $\{\mathbf{A}^n_{S_i} \to \mathbf{A}^n_S\}$ is a
fpqc covering we see from
Descent, Lemma \ref{descent-lemma-descending-property-regular-immersion}
that $j$ is a Koszul-regular immersion as desired.
\end{proof}

\begin{lemma}
\label{lemma-lci-syntomic-local-source}
The property $\mathcal{P}(f) =$``$f$ is a local complete intersection
morphism'' is syntomic local on the source.
\end{lemma}

\begin{proof}
We will use the criterion of
Descent, Lemma \ref{descent-lemma-properties-morphisms-local-source}
to prove this. It follows from
Lemmas \ref{lemma-flat-lci} and
\ref{lemma-composition-lci}
that being a local complete intersection morphism is preserved under
precomposing with syntomic morphisms. It is clear from
Definition \ref{definition-lci}
that being a local complete intersection morphism is Zariski local on the
source and target. Hence, according to the aforementioned
Descent, Lemma \ref{descent-lemma-properties-morphisms-local-source}
it suffices to prove the following: Suppose $X' \to X \to Y$ are
morphisms of affine schemes with $X' \to X$ syntomic and $X' \to Y$
a local complete intersection morphism. Then $X \to Y$ is a local complete
intersection morphism. To see this, note that in any case $X \to Y$ is of
finite presentation by
Descent, Lemma \ref{descent-lemma-flat-finitely-presented-permanence-algebra}.
Choose a closed immersion $X \to \mathbf{A}^n_Y$. By
Algebra, Lemma \ref{algebra-lemma-lift-syntomic}
we can find an affine open covering $X' = \bigcup_{i = 1, \ldots, n} X'_i$
and syntomic morphisms $W_i \to \mathbf{A}^n_Y$ lifting the morphisms
$X'_i \to X$, i.e., such that there are fibre product diagrams
$$
\xymatrix{
X'_i \ar[d] \ar[r] & W_i \ar[d] \\
X \ar[r] & \mathbf{A}^n_Y
}
$$
After replacing $X'$ by $\coprod X'_i$ and setting $W = \coprod W_i$
we obtain a fibre product diagram of affine schemes
$$
\xymatrix{
X' \ar[d] \ar[r] & W \ar[d]^h \\
X \ar[r] & \mathbf{A}^n_Y
}
$$
with $h : W \to \mathbf{A}^n_Y$ syntomic and $X' \to Y$ still a local complete
intersection morphism. Since $W \to \mathbf{A}^n_Y$ is open (see
Morphisms, Lemma \ref{morphisms-lemma-fppf-open})
and $X' \to X$ is surjective we see that $X$ is contained in the image
of $W \to \mathbf{A}^n_Y$. Choose a closed immersion
$W \to \mathbf{A}^{n + m}_Y$ over $\mathbf{A}^n_Y$. Now the diagram looks like
$$
\xymatrix{
X' \ar[d] \ar[r] & W \ar[d]^h \ar[r] & \mathbf{A}^{n + m}_Y \ar[ld] \\
X \ar[r] & \mathbf{A}^n_Y
}
$$
Because $h$ is syntomic and hence a local complete intersection morphism (see
above) the morphism $W \to \mathbf{A}^{n + m}_Y$ is a Koszul-regular immersion.
Because $X' \to Y$ is a local complete intersection morphism the morphism
$X' \to \mathbf{A}^{n + m}_Y$ is a Koszul-regular immersion. We conclude from
Divisors, Lemma \ref{divisors-lemma-permanence-regular-immersion}
that $X' \to W$ is a Koszul-regular immersion. Hence, since being
a Koszul-regular immersion is fpqc local on the target (see
Descent, Lemma \ref{descent-lemma-descending-property-regular-immersion})
we conclude that $X \to \mathbf{A}^n_Y$ is a Koszul-regular immersion
which is what we had to show.
\end{proof}

\begin{lemma}
\label{lemma-base-change-lci-fibres}
Let $S$ be a scheme. Let $f : X \to Y$ be a morphism of schemes over $S$.
Assume both $X$ and $Y$ are flat and locally of finite presentation over $S$.
Then the set
$$
\{x \in X \mid f\text{ Koszul at }x\}.
$$
is open in $X$ and its formation commutes with arbitrary base change
$S' \to S$.
\end{lemma}

\begin{proof}
The set is open by definition (see
Definition \ref{definition-lci}).
Let $S' \to S$ be a morphism of schemes. Set $X' = S' \times_S X$,
$Y' = S' \times_S Y$, and denote $f' : X' \to Y'$ the base change of $f$.
Let $x' \in X'$ be a point such that $f'$ is Koszul at $x'$. Denote
$s' \in S'$, $x \in X$, $y' \in Y'$ , $y \in Y$, $s \in S$ the image
of $x'$. Note that $f$ is locally of finite presentation, see
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}.
Hence we may choose an affine neighbourhood $U \subset X$ of
$x$ and an immersion $i : U \to \mathbf{A}^n_Y$. Denote $U' = S' \times_S U$
and $i' : U' \to \mathbf{A}^n_{Y'}$ the base change of $i$.
The assumption that $f'$ is Koszul at $x'$ implies that $i'$ is a
Koszul-regular immersion in a neighbourhood of $x'$, see
Lemma \ref{lemma-lci}.
The scheme $X'$ is flat and locally of finite
presentation over $S'$ as a base change of $X$ (see
Morphisms, Lemmas \ref{morphisms-lemma-base-change-flat} and
\ref{morphisms-lemma-base-change-finite-presentation}).
Hence $i'$ is a relative $H_1$-regular immersion over $S'$
in a neighbourhood of $x'$ (see
Divisors, Definition \ref{divisors-definition-relative-H1-regular-immersion}).
Thus the base change $i'_{s'} : U'_{s'} \to \mathbf{A}^n_{Y'_{s'}}$ is
a $H_1$-regular immersion in an open neighbourhood of $x'$, see
Divisors, Lemma \ref{divisors-lemma-relative-regular-immersion}
and the discussion following
Divisors, Definition \ref{divisors-definition-relative-H1-regular-immersion}.
Since $s' = \Spec(\kappa(s')) \to \Spec(\kappa(s)) = s$
is a surjective flat universally open morphism (see
Morphisms, Lemma \ref{morphisms-lemma-scheme-over-field-universally-open})
we conclude that the base change $i_s : U_s \to \mathbf{A}^n_{Y_s}$ is an
$H_1$-regular immersion in a neighbourhood of $x$, see
Descent, Lemma \ref{descent-lemma-descending-property-regular-immersion}.
Finally, note that $\mathbf{A}^n_Y$ is flat and locally of finite
presentation over $S$, hence
Divisors, Lemma \ref{divisors-lemma-fibre-quasi-regular}
implies that $i$ is a (Koszul-)regular immersion in a neighbourhood of $x$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-unramified-lci}
Let $f : X \to Y$ be a local complete intersection morphism of schemes.
Then $f$ is unramified if and only if $f$ is formally unramified and in
this case the conormal sheaf $\mathcal{C}_{X/Y}$ is finite locally free
on $X$.
\end{lemma}

\begin{proof}
The first assertion follows immediately from
Lemma \ref{lemma-unramified-formally-unramified}
and the fact that a local complete intersection morphism is locally
of finite type. To compute the conormal sheaf of $f$ we choose, locally
on $X$, a factorization of $f$ as $f = p \circ i$ where $i : X \to V$
is a Koszul-regular immersion and $V \to Y$ is smooth. By
Lemma \ref{lemma-two-unramified-morphisms-formally-smooth}
we see that $\mathcal{C}_{X/Y}$ is a locally direct summand of
$\mathcal{C}_{X/V}$ which is finite locally free as $i$ is a Koszul-regular
(hence quasi-regular) immersion, see
Divisors, Lemma \ref{divisors-lemma-quasi-regular-immersion}.
\end{proof}

\begin{lemma}
\label{lemma-transitivity-conormal-lci}
Let $Z \to Y \to X$ be formally unramified morphisms of schemes.
Assume that $Z \to Y$ is a local complete intersection morphism.
The exact sequence
$$
0 \to i^*\mathcal{C}_{Y/X} \to
\mathcal{C}_{Z/X} \to
\mathcal{C}_{Z/Y} \to 0
$$
of
Lemma \ref{lemma-transitivity-conormal}
is short exact.
\end{lemma}

\begin{proof}
The question is local on $Z$ hence we may assume there exists a factorization
$Z \to \mathbf{A}^n_Y \to Y$ of the morphism $Z \to Y$. Then we get a
commutative diagram
$$
\xymatrix{
Z \ar[r]_{i'} \ar@{=}[d] &
\mathbf{A}^n_Y \ar[r] \ar[d] &
\mathbf{A}^n_X \ar[d] \\
Z \ar[r]^i & Y \ar[r] & X
}
$$
As $Z \to Y$ is a local complete intersection morphism, we see that
$Z \to \mathbf{A}^n_Y$ is a Koszul-regular immersion. Hence by
Divisors, Lemma \ref{divisors-lemma-transitivity-conormal-quasi-regular}
the sequence
$$
0 \to (i')^*\mathcal{C}_{\mathbf{A}^n_Y/\mathbf{A}^n_X} \to
\mathcal{C}_{Z/\mathbf{A}^n_X} \to
\mathcal{C}_{Z/\mathbf{A}^n_Y} \to 0
$$
is exact and locally split. Note that
$i^*\mathcal{C}_{Y/X} = (i')^*\mathcal{C}_{\mathbf{A}^n_Y/\mathbf{A}^n_X}$
by
Lemma \ref{lemma-universal-thickening-fibre-product-flat}
and note that the diagram
$$
\xymatrix{
(i')^*\mathcal{C}_{\mathbf{A}^n_Y/\mathbf{A}^n_X} \ar[r] &
\mathcal{C}_{Z/\mathbf{A}^n_X} \\
i^*\mathcal{C}_{Y/X} \ar[u]^{\cong} \ar[r] & \mathcal{C}_{Z/X} \ar[u]
}
$$
is commutative. Hence the lower horizontal arrow is a locally split
injection. This proves the lemma.
\end{proof}













\section{Exact sequences of differentials and conormal sheaves}
\label{section-exact}

\noindent
In this section we collect some results on exact sequences of conormal
sheaves and sheaves of differentials. In some sense these are all
realizations of the triangle of cotangent complexes associated to a pair of
composable morphisms of schemes.

\medskip\noindent
Let $g : Z \to Y$ and $f : Y \to X$ be morphisms of schemes.
\begin{enumerate}
\item There is a canonical exact sequence
$$
g^*\Omega_{Y/X} \to \Omega_{Z/X} \to \Omega_{Z/Y} \to 0,
$$
see
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials}.
If $g : Z \to Y$ is smooth or more generally formally smooth, then this
sequence is a short exact sequence, see
Morphisms, Lemma \ref{morphisms-lemma-triangle-differentials-smooth}
or see Lemma \ref{lemma-triangle-differentials-formally-smooth}.
\item If $g$ is an immersion or more generally formally unramified,
then there is a canonical exact sequence
$$
\mathcal{C}_{Z/Y} \to g^*\Omega_{Y/X} \to \Omega_{Z/X} \to 0,
$$
see Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion}
or see Lemma \ref{lemma-universally-unramified-differentials-sequence}.
If $f \circ g : Z \to X$ is smooth or more generally formally smooth, then this
sequence is a short exact sequence, see
Morphisms, Lemma \ref{morphisms-lemma-differentials-relative-immersion-smooth}
or see Lemma \ref{lemma-differentials-formally-unramified-formally-smooth}.
\item If $g$ and $f \circ g$ are immersions or more generally
formally unramified, then there is a canonical exact sequence
$$
\mathcal{C}_{Z/X} \to \mathcal{C}_{Z/Y} \to g^*\Omega_{Y/X} \to 0,
$$
see
Morphisms, Lemma \ref{morphisms-lemma-two-immersions} or see
Lemma \ref{lemma-two-unramified-morphisms}. If $f : Y \to X$ is smooth or
more generally formally smooth, then this sequence is a short exact sequence,
see Morphisms, Lemma \ref{morphisms-lemma-two-immersions-smooth} or see
Lemma \ref{lemma-two-unramified-morphisms-formally-smooth}.
\item If $g$ and $f$ are immersions or more generally formally unramified, then
there is a canonical exact sequence
$$
g^*\mathcal{C}_{Y/X} \to \mathcal{C}_{Z/X} \to \mathcal{C}_{Z/Y} \to 0.
$$
see
Morphisms, Lemma \ref{morphisms-lemma-transitivity-conormal} or see
Lemma \ref{lemma-transitivity-conormal}.
If $g : Z \to Y$ is a regular immersion\footnote{It suffices for $g$ to be
a $H_1$-regular immersion. Observe that an immersion which is a
local complete intersection morphism is Koszul regular.} or
more generally a local complete intersection morphism, then this
sequence is a short exact sequence, see
Divisors, Lemma \ref{divisors-lemma-transitivity-conormal-quasi-regular}
or see Lemma \ref{lemma-transitivity-conormal-lci}.
\end{enumerate}










\section{Weakly \'etale morphisms}
\label{section-weakly-etale}

\noindent
A ring homomorphism $A \to B$ is weakly \'etale if both $A \to B$ and
$B \otimes_A B \to B$ are flat, see
More on Algebra, Definition \ref{more-algebra-definition-weakly-etale}.
The analogous notion for morphisms of schemes is the following.

\begin{definition}
\label{definition-weakly-etale}
A morphism of schemes $X \to Y$ is {\it weakly \'etale} or
{\it absolutely flat} if both $X \to Y$ and the diagonal
morphism $X \to X \times_Y X$ are flat.
\end{definition}

\noindent
An \'etale morphism is weakly \'etale and conversely
it turns out that a weakly \'etale morphism is indeed somewhat
like an \'etale morphism. For example, if $X \to Y$ is weakly
\'etale, then $L_{X/Y} = 0$, as follows from
Cotangent, Lemma \ref{cotangent-lemma-when-zero}.
We will prove a very precise result relating weakly \'etale
morphisms to \'etale morphisms later (see
Pro-\'etale Cohomology, Section \ref{proetale-section-weakly-etale}).
In this section we stick with the basics.

\begin{lemma}
\label{lemma-check-weakly-etale-stalks}
Let $f : X \to Y$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item $X \to Y$ is weakly \'etale, and
\item for every $x \in X$ the ring map
$\mathcal{O}_{Y, f(x)} \to \mathcal{O}_{X, x}$ is weakly \'etale.
\end{enumerate}
\end{lemma}

\begin{proof}
Observe that under both assumptions (1) and (2) the morphism $f$ is flat.
Thus we may assume $f$ is flat. Let $x \in X$ with image $y = f(x)$ in $Y$.
There are canonical maps of rings
$$
\mathcal{O}_{X, x} \otimes_{\mathcal{O}_{Y, y}} \mathcal{O}_{X, x}
\longrightarrow
\mathcal{O}_{X \times_Y X, \Delta_{X/Y}(x)}
\longrightarrow
\mathcal{O}_{X, x}
$$
where the first map is a localization (hence flat) and the second map is a
surjection (hence an epimorphism of rings).
Condition (1) means that for all $x$ the second arrow is flat.
Condition (2) is that for all $x$ the composition is flat.
These conditions are equivalent by
Algebra, Lemma \ref{algebra-lemma-composition-flat} and
More on Algebra, Lemma \ref{more-algebra-lemma-key}.
\end{proof}

\begin{lemma}
\label{lemma-key}
Let $X \to Y$ be a morphism of schemes such that
$X \to X \times_Y X$ is flat. Let $\mathcal{F}$ be an $\mathcal{O}_X$-module.
If $\mathcal{F}$ is flat over $Y$, then $\mathcal{F}$ is flat over $X$.
\end{lemma}

\begin{proof}
Let $x \in X$ with image $y = f(x)$ in $Y$.
Since $X \to X \times_Y X$ is flat, we see that
$\mathcal{O}_{X, x} \otimes_{\mathcal{O}_{Y, y}} \mathcal{O}_{X, x} \to
\mathcal{O}_{X, x}$ is flat. Hence the result follows from
More on Algebra, Lemma \ref{more-algebra-lemma-key}
and the definitions.
\end{proof}

\begin{lemma}
\label{lemma-weakly-etale-characterize}
Let $f : X \to S$ be a morphism of schemes. The following are equivalent
\begin{enumerate}
\item The morphism $f$ is weakly \'etale.
\item For every affine opens $U \subset X$, $V \subset S$
with $f(U) \subset V$ the ring map
$\mathcal{O}_S(V) \to \mathcal{O}_X(U)$ is weakly \'etale.
\item There exists an open covering $S = \bigcup_{j \in J} V_j$
and open coverings $f^{-1}(V_j) = \bigcup_{i \in I_j} U_i$ such
that each of the morphisms $U_i \to V_j$, $j\in J, i\in I_j$
is weakly \'etale.
\item There exists an affine open covering $S = \bigcup_{j \in J} V_j$
and affine open coverings $f^{-1}(V_j) = \bigcup_{i \in I_j} U_i$ such
that the ring map $\mathcal{O}_S(V_j) \to \mathcal{O}_X(U_i)$ is
of weakly \'etale, for all $j\in J, i\in I_j$.
\end{enumerate}
Moreover, if $f$ is weakly \'etale then for
any open subschemes $U \subset X$, $V \subset S$ with $f(U) \subset V$
the restriction $f|_U : U \to V$ is weakly-\'etale.
\end{lemma}

\begin{proof}
Suppose given open subschemes $U \subset X$, $V \subset S$ with
$f(U) \subset V$. Then $U \times_V U \subset X \times_Y X$ is open
(Schemes, Lemma \ref{schemes-lemma-open-fibre-product})
and the diagonal $\Delta_{U/V}$ of $f|_U : U \to V$ is
the restriction $\Delta_{X/Y}|_U : U \to U \times_V U$.
Since flatness is a local property of morphisms of schemes
(Morphisms, Lemma \ref{morphisms-lemma-flat-characterize})
the final statement of the lemma is follows
as well as the equivalence of (1) and (3).
If $X$ and $Y$ are affine, then $X \to Y$ is weakly \'etale
if and only if $\mathcal{O}_Y(Y) \to \mathcal{O}_X(X)$ is
weakly \'etale (use again
Morphisms, Lemma \ref{morphisms-lemma-flat-characterize}).
Thus (1) and (3) are also equivalent to (2) and (4).
\end{proof}

\begin{lemma}
\label{lemma-composition-weakly-etale}
Let $X \to Y \to Z$ be morphisms of schemes.
\begin{enumerate}
\item If $X \to X \times_Y X$ and $Y \to Y \times_Z Y$ are flat,
then $X \to X \times_Z X$ is flat.
\item If $X \to Y$ and $Y \to Z$ are weakly \'etale, then
$X \to Z$ is weakly \'etale.
\end{enumerate}
\end{lemma}

\begin{proof}
Part (1) follows from the factorization
$$
X \to X \times_Y X \to X \times_Z X
$$
of the diagonal of $X$ over $Z$, the fact that
$$
X \times_Y X = (X \times_Z X) \times_{(Y \times_Z Y)} Y,
$$
the fact that a base change of a flat morphism is flat, and
the fact that the composition of flat morphisms is flat
(Morphisms, Lemmas \ref{morphisms-lemma-base-change-flat} and
\ref{morphisms-lemma-composition-flat}).
Part (2) follows from part (1) and the fact (just used)
that the composition of flat morphisms is flat.
\end{proof}

\begin{lemma}
\label{lemma-base-change-weakly-etale}
Let $X \to Y$ and $Y' \to Y$ be morphisms of schemes and let
$X' = Y' \times_Y X$ be the base change of $X$.
\begin{enumerate}
\item If $X \to X \times_Y X$ is flat, then $X' \to X' \times_{Y'} X'$
is flat.
\item If $X \to Y$ is weakly \'etale, then $X' \to Y'$ is weakly \'etale.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume $X \to X \times_Y X$ is flat. The morphism $X' \to X' \times_{Y'} X'$
is the base change of $X \to X \times_Y X$ by $Y' \to Y$. Hence it
is flat by Morphisms, Lemmas \ref{morphisms-lemma-base-change-flat}.
This proves (1). Part (2) follows from (1) and the fact (just used)
that the base change of a flat morphism is flat.
\end{proof}

\begin{lemma}
\label{lemma-go-down}
Let $X \to Y \to Z$ be morphisms of schemes. Assume that $X \to Y$ is
flat and surjective and that $X \to X \times_Z X$ is flat.
Then $Y \to Y \times_Z Y$ is flat.
\end{lemma}

\begin{proof}
Consider the commutative diagram
$$
\xymatrix{
X \ar[r] \ar[d] & X \times_Z X \ar[d] \\
Y \ar[r] & Y \times_Z Y
}
$$
The top horizontal arrow is flat and the vertical arrows are flat.
Hence $X$ is flat over $Y \times_Z Y$. By
Morphisms, Lemma \ref{morphisms-lemma-flat-permanence}
we see that $Y$ is flat over $Y \times_Z Y$.
\end{proof}

\begin{lemma}
\label{lemma-weakly-etale-formally-unramified}
Let $f : X \to Y$ be a weakly \'etale morphism of schemes.
Then $f$ is formally unramified, i.e., $\Omega_{X/Y} = 0$.
\end{lemma}

\begin{proof}
Recall that $f$ is formally unramified if and only if $\Omega_{X/Y} = 0$ by
Lemma \ref{lemma-formally-unramified-differentials}.
Via Lemma \ref{lemma-weakly-etale-characterize} and
Morphisms, Lemma \ref{morphisms-lemma-differentials-affine}
this follows from the case of rings which is
More on Algebra, Lemma \ref{more-algebra-lemma-formally-unramified}.
\end{proof}

\begin{lemma}
\label{lemma-when-weakly-etale}
Let $f : X \to Y$ be a morphism of schemes. Then $X \to Y$ is weakly \'etale
in each of the following cases
\begin{enumerate}
\item $X \to Y$ is a flat monomorphism,
\item $X \to Y$ is an open immersion,
\item $X \to Y$ is flat and unramified,
\item $X \to Y$ is \'etale.
\end{enumerate}
\end{lemma}

\begin{proof}
If (1) holds, then $\Delta_{X/Y}$ is an isomorphism
(Schemes, Lemma \ref{schemes-lemma-monomorphism}), hence certainly
$f$ is weakly \'etale. Case (2) is a special case of (1).
The diagonal of an unramified morphism is an open immersion
(Morphisms, Lemma \ref{morphisms-lemma-diagonal-unramified-morphism}),
hence flat. Thus a flat unramified morphism is weakly \'etale.
An \'etale morphism is flat and unramified
(Morphisms, Lemma \ref{morphisms-lemma-etale-smooth-unramified}),
hence (4) follows from (3).
\end{proof}

\begin{lemma}
\label{lemma-reduced-goes-up}
Let $f : X \to Y$ be a morphism of schemes.
If $Y$ is reduced and $f$ weakly \'etale, then $X$ is reduced.
\end{lemma}

\begin{proof}
Via Lemma \ref{lemma-weakly-etale-characterize}
this follows from the case of rings which is
More on Algebra, Lemma
\ref{more-algebra-lemma-absolutely-flat-over-absolutely-flat}.
\end{proof}

\noindent
The following lemma uses a nontrivial result about weakly
\'etale ring maps.

\begin{lemma}
\label{lemma-weakly-etale-strictly-henselian-local-rings}
Let $f : X \to Y$ be a morphism of schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is weakly \'etale, and
\item for $x \in X$ the local ring map
$\mathcal{O}_{Y, f(x)} \to \mathcal{O}_{X, x}$ induces an isomorphism
on strict henselizations.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $x \in X$ be a point with image $y = f(x)$ in $Y$.
Choose a separable algebraic closure $\kappa^{sep}$ of $\kappa(x)$.
Let $\mathcal{O}_{X, x}^{sh}$ be the strict henselization
corresponding to $\kappa^{sep}$ and $\mathcal{O}_{Y, y}^{sh}$
the strict henselization relative to the separable algebraic
closure of $\kappa(y)$ in $\kappa^{sep}$.
Consider the commutative diagram
$$
\xymatrix{
\mathcal{O}_{X, x} \ar[r] & \mathcal{O}_{X, x}^{sh} \\
\mathcal{O}_{Y, y} \ar[u] \ar[r] & \mathcal{O}_{Y, y}^{sh} \ar[u]
}
$$
local homomorphisms of local rings, see
Algebra, Lemma \ref{algebra-lemma-strictly-henselian-functorial}.
Since the strict henselization is a filtered colimit of \'etale
ring maps, More on Algebra, Lemma \ref{more-algebra-lemma-when-weakly-etale}
shows the horizontal maps are weakly \'etale.
Moreover, the horizontal maps are faithfully flat by
More on Algebra, Lemma \ref{more-algebra-lemma-dumb-properties-henselization}.

\medskip\noindent
Assume $f$ weakly \'etale. By Lemma \ref{lemma-check-weakly-etale-stalks}
the left vertical arrow is weakly \'etale. By
More on Algebra, Lemmas \ref{more-algebra-lemma-composition-weakly-etale} and
\ref{more-algebra-lemma-weakly-etale-permanence}
the right vertical arrow is weakly \'etale. By
More on Algebra, Theorem \ref{more-algebra-theorem-olivier}
we conclude the right vertical map is an isomorphism.

\medskip\noindent
Assume $\mathcal{O}_{Y, y}^{sh} \to \mathcal{O}_{X, x}^{sh}$ is an isomorphism.
Then $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}^{sh}$ is weakly \'etale.
Since $\mathcal{O}_{X, x} \to \mathcal{O}_{X, x}^{sh}$ is faithfully
flat we conclude that $\mathcal{O}_{Y, y} \to \mathcal{O}_{X, x}$
is weakly \'etale by
More on Algebra, Lemma \ref{more-algebra-lemma-go-down}.
Thus (2) implies (1) by Lemma \ref{lemma-check-weakly-etale-stalks}.
\end{proof}

\begin{lemma}
\label{lemma-normal-goes-up}
Let $f : X \to Y$ be a morphism of schemes. If $Y$ is a normal scheme
and $f$ weakly \'etale, then $X$ is a normal scheme.
\end{lemma}

\begin{proof}
By More on Algebra, Lemma \ref{more-algebra-lemma-henselization-normal}
a scheme $S$ is normal if and only if for all $s \in S$
the strict henselization of $\mathcal{O}_{S, s}$ is a normal domain.
Hence the lemma follows from
Lemma \ref{lemma-weakly-etale-strictly-henselian-local-rings}.
\end{proof}

\begin{lemma}
\label{lemma-weakly-etale-permanence}
Let $S$ be a scheme. Let $f : X \to Y$ be a morphism of schemes over $S$.
If $X$, $Y$ are weakly \'etale over $S$, then $f$ is weakly \'etale.
\end{lemma}

\begin{proof}
We will use Morphisms, Lemmas \ref{morphisms-lemma-base-change-flat} and
\ref{morphisms-lemma-composition-flat} without further mention.
Write $X \to Y$ as the composition $X \to X \times_S Y \to Y$.
The second morphism is flat as the base change of the flat morphism
$X \to S$. The first is the base change of the flat morphism
$Y \to Y \times_S Y$ by the morphism $X \times_S Y \to Y \times_S Y$,
hence flat. Thus $X \to Y$ is flat. The morphism
$X \times_Y X \to X \times_S X$ is an immersion.
Thus Lemma \ref{lemma-key} implies, that since
$X$ is flat over $X \times_S X$ it follows that $X$ is
flat over $X \times_Y X$.
\end{proof}

\noindent
The following is a scheme theoretic generalization of the observation
that a field extension that is simultaneously separable and purely inseparable
must be an isomorphism. 

\begin{lemma}
\label{lemma-weakly-etale-universal-homeomorphism}
Let $f : X \to Y$ be a morphism of schemes. If $f$ is weakly \'etale and
a universal homeomorphism, it is an isomorphism. 
\end{lemma}

\begin{proof}
Since $f$ is a universal homeomorphism, the diagonal
$\Delta : X \to X \times_Y X$ is a surjective closed immersion by
Morphisms, Lemmas \ref{morphisms-lemma-homeomorphism-affine} and
\ref{morphisms-lemma-universally-injective}. Since $\Delta$ is also
flat, we see that $\Delta$ must be an isomorphism by
Morphisms, Lemma \ref{morphisms-lemma-characterize-flat-closed-immersions}.
In other words, $f$ is a monomorphism
(Schemes, Lemma \ref{schemes-lemma-monomorphism}).
Since $f$ is a universal homeomorphism it is certainly
quasi-compact. Hence by Descent, Lemma
\ref{descent-lemma-flat-surjective-quasi-compact-monomorphism-isomorphism}
we find that $f$ is an isomorphism.
\end{proof}

\noindent
The following is a weakly \'etale generalization of
\'Etale Morphisms, Lemma \ref{etale-lemma-relative-frobenius-etale}.

\begin{lemma}
\label{lemma-relative-frobenius-weakly-etale}
Let $U \to X$ be a weakly \'etale morphism of schemes where $X$ is a scheme
in characteristic $p$. Then the relative Frobenius
$F_{U/X} : U \to U \times_{X, F_X} X$ is an isomorphism.
\end{lemma}

\begin{proof}
The morphism $F_{U/X}$ is a universal homeomorphism by
Varieties, Lemma \ref{varieties-lemma-relative-frobenius}.
The morphism $F_{U/X}$ is weakly \'etale as a morphism
between schemes weakly \'etale over $X$ by
Lemma \ref{lemma-weakly-etale-permanence}. Hence $F_{U/X}$
is an isomorphism by Lemma \ref{lemma-weakly-etale-universal-homeomorphism}.
\end{proof}






\section{Reduced fibre theorem}
\label{section-reduced-fibre-theorem}

\noindent
In this section we discuss the simplest kind of theorem of the kind
advertised by the title. Although the proof of the result is kind of
laborious, in essence it follows in a straightforward manner from
Epp's result on eliminating ramification, see
More on Algebra, Theorem \ref{more-algebra-theorem-epp}.

\medskip\noindent
Let $A$ be a Dedekind domain with fraction field $K$.
Let $X$ be a scheme flat and of finite type over $A$.
Let $L$ be a finite extension of $K$. Let $B$ be the integral
closure of $A$ in $L$. Then $B$ is a Dedekind domain
(Algebra, Lemma \ref{algebra-lemma-integral-closure-Dedekind}).
Let $X_B = X \times_{\Spec(A)} \Spec(B)$ be the base change.
Then $X_B \to \Spec(B)$ is of finite type
(Morphisms, Lemma \ref{morphisms-lemma-base-change-finite-type}).
Hence $X_B$ is Noetherian
(Morphisms, Lemma \ref{morphisms-lemma-finite-type-noetherian}).
Thus the normalization $\nu : Y \to X_B$ exists (see
Morphisms, Definition \ref{morphisms-definition-normalization}
and the discussion following). Picture
\begin{equation}
\label{equation-normalized-base-change}
\xymatrix{
Y \ar[rd] \ar[r]_\nu & X_B \ar[r] \ar[d] & X \ar[d] \\
 & \Spec(B) \ar[r] & \Spec(A)
}
\end{equation}
We sometimes call $Y$ the {\it normalized base change} of $X$.
In general the morphism $\nu$ may not be finite. But if $A$ is
a Nagata ring (a condition that is virtually always satisfied in
practice) then $\nu$ is finite and $Y$ is of finite type over $B$, see
Morphisms, Lemmas \ref{morphisms-lemma-nagata-normalization} and
\ref{morphisms-lemma-finite-type-nagata}.

\medskip\noindent
Taking the normalized base change commutes with composition.
More precisely, if $M/L/K$ are finite extensions
of fields with integral closures $A \subset B \subset C$
then the normalized base change $Z$ of $Y \to \Spec(B)$
relative to $M/L$ is equal to the normalized base change
of $X \to \Spec(A)$ relative to $M/K$.

\begin{theorem}
\label{theorem-normalized-base-change-with-reduced-fibre}
Let $A$ be a Dedekind ring with fraction field $K$.
Let $X$ be a scheme flat and of finite type over $A$.
Assume $A$ is a Nagata ring.
There exists a finite extension $L/K$ such that
the normalized base change $Y$ is smooth over $\Spec(B)$
at all generic points of all fibres.
\end{theorem}

\begin{proof}
During the proof we will repeatedly use that formation of the set of points
where a (flat, finitely presented) morphism like $X \to \Spec(A)$ is
smooth commutes with base change, see
Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-smooth}.

\medskip\noindent
We first choose a finite extension $L/K$ such that
$(X_L)_{red}$ is geometrically reduced over $L$, see
Varieties, Lemma \ref{varieties-lemma-finite-extension-geometrically-reduced}.
Since $Y \to (X_B)_{red}$ is birational we see applying
Varieties, Lemma \ref{varieties-lemma-generic-points-geometrically-reduced}
that $Y_L$ is geometrically reduced over $L$ as well.
Hence $Y_L \to \Spec(L)$ is smooth on a dense open $V \subset Y_L$ by
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-dense-smooth-open}.
Thus the smooth locus $U \subset Y$ of the morphism $Y \to \Spec(B)$
is open (by Morphisms, Definition \ref{morphisms-definition-smooth})
and is dense in the generic fibre. Replacing $A$ by $B$ and $X$ by $Y$
we reduce to the case treated in the next paragraph.

\medskip\noindent
Assume $X$ is normal and the smooth locus $U \subset X$ of $X \to \Spec(A)$
is dense in the generic fibre. This implies that $U$ is dense in all but
finitely many fibres, see Lemma \ref{lemma-nowhere-dense-generic-fibre}.
Let $x_1, \ldots, x_r \in X \setminus U$ be the finitely many generic
points of irreducible components of $X \setminus U$ which are moreover
generic points of irreducible components of fibres of $X \to \Spec(A)$.
Set $\mathcal{O}_i = \mathcal{O}_{X, x_i}$. Let $A_i$ be the localization of
$A$ at the maximal ideal corresponding to the image of $x_i$ in $\Spec(A)$.
By
More on Algebra, Proposition
\ref{more-algebra-proposition-epp-essentially-finite-type}
there exist finite extensions
$K_i/K$ which are solutions for the extension of discrete valuation
rings $A_i \to \mathcal{O}_i$. Let $L/K$ be a finite extension
dominating all of the extensions $K_i/K$. Then $L/K$
is still a solution for $A_i \to \mathcal{O}_i$ by
More on Algebra, Lemma \ref{more-algebra-lemma-solution-goes-up}.

\medskip\noindent
Consider the diagram (\ref{equation-normalized-base-change})
with the extension $L/K$ we just produced. Note that $U_B \subset X_B$
is smooth over $B$, hence normal (for example use
Algebra, Lemma \ref{algebra-lemma-normal-goes-up}).
Thus $Y \to X_B$ is an isomorphism over $U_B$.
Let $y \in Y$ be a generic point of an irreducible
component of a fibre of $Y \to \Spec(B)$ lying over the maximal
ideal $\mathfrak m \subset B$. Assume that $y \not \in U_B$.
Then $y$ maps to one of the points $x_i$. It follows that
$\mathcal{O}_{Y, y}$ is a local ring of the integral closure
of $\mathcal{O}_i$ in $R(X) \otimes_K L$ (details omitted).
Hence because $L/K$ is a solution for
$A_i \to \mathcal{O}_i$ we see that
$B_\mathfrak m \to \mathcal{O}_{Y, y}$ is formally smooth
in the $\mathfrak m_y$-adic topology
(this is the definition of being a "solution").
In other words, $\mathfrak m\mathcal{O}_{Y, y} = \mathfrak m_y$
and the residue field extension is separable, see
More on Algebra, Lemma \ref{more-algebra-lemma-extension-dvrs-formally-smooth}.
Hence the local ring
of the fibre at $y$ is $\kappa(y)$.
This implies the fibre is smooth over $\kappa(\mathfrak m)$
at $y$ for example by Algebra, Lemma \ref{algebra-lemma-separable-smooth}.
This finishes the proof.
\end{proof}

\begin{lemma}[Variant over curves]
\label{lemma-normalized-base-change-with-reduced-fibre-over-curve}
Let $f : X \to S$ be a flat, finite type morphism of schemes.
Assume $S$ is Nagata, integral with function field $K$, and
regular of dimension $1$. Then there exists a finite extension $L/K$
such that in the diagram
$$
\xymatrix{
Y \ar[rd]_g \ar[r]_-\nu & X \times_S T \ar[d] \ar[r] & X \ar[d]_f \\
& T \ar[r] & S
}
$$
the morphism $g$ is smooth at all generic points of fibres. Here
$T$ is the normalization of $S$ in $\Spec(L)$ and $\nu : Y \to X \times_S T$
is the normalization.
\end{lemma}

\begin{proof}
Choose a finite affine open covering $S = \bigcup \Spec(A_i)$.
Then $K$ is equal to the fraction field of $A_i$ for all $i$.
Let $X_i = X \times_S \Spec(A_i)$.
Choose $L_i/K$ as in
Theorem \ref{theorem-normalized-base-change-with-reduced-fibre}
for the morphism $X_i \to \Spec(A_i)$.
Let $B_i \subset L_i$ be the integral closure of $A_i$ and
let $Y_i$ be the normalized base change of $X$ to $B_i$.
Let $L/K$ be a finite extension dominating each $L_i$.
Let $T_i \subset T$ be the inverse image of $\Spec(A_i)$.
For each $i$ we get a commutative diagram
$$
\xymatrix{
g^{-1}(T_i) \ar[r] \ar[d] & Y_i \ar[r] \ar[d] & X \times_S \Spec(A_i) \ar[d] \\
T_i \ar[r] & \Spec(B_i) \ar[r] & \Spec(A_i)
}
$$
and in fact the left hand square is a normalized base change
as discussed at the beginning of the section. In the proof
of Theorem \ref{theorem-normalized-base-change-with-reduced-fibre}
we have seen that the smooth locus of $Y \to T$ contains the
inverse image in $g^{-1}(T_i)$ of the set of points
where $Y_i$ is smooth over $B_i$. This proves the lemma.
\end{proof}

\begin{lemma}[Variant with separable extension]
\label{lemma-normalized-base-change-with-reduced-fibre-separable}
Let $A$ be a Dedekind ring with fraction field $K$.
Let $X$ be a scheme flat and of finite type over $A$.
Assume $A$ is a Nagata ring and that for every generic point
$\eta$ of an irreducible component of $X$ the field
extension $\kappa(\eta)/K$ is separable.
Then there exists a finite separable extension $L/K$ such that
the normalized base change $Y$ is smooth over $\Spec(B)$
at all generic points of all fibres.
\end{lemma}

\begin{proof}
This is proved in exactly the same manner as
Theorem \ref{theorem-normalized-base-change-with-reduced-fibre}
with a few minor modifications. The most important change
is to use More on Algebra, Lemma
\ref{more-algebra-lemma-epp-essentially-finite-type-separable}
instead of More on Algebra, Proposition
\ref{more-algebra-proposition-epp-essentially-finite-type}.
During the proof we will repeatedly use that formation of the set of points
where a (flat, finitely presented) morphism like $X \to \Spec(A)$ is
smooth commutes with base change, see
Morphisms, Lemma \ref{morphisms-lemma-set-points-where-fibres-smooth}.

\medskip\noindent
Since $X$ is flat over $A$ every generic point $\eta$ of $X$ maps to the
generic point of $\Spec(A)$.
After replacing $X$ by its reduction we may assume $X$ is reduced.
In this case $X_K$ is geometrically reduced over $K$
by Varieties, Lemma \ref{varieties-lemma-generic-points-geometrically-reduced}.
Hence $X_K \to \Spec(K)$ is smooth on a dense open by
Varieties, Lemma \ref{varieties-lemma-geometrically-reduced-dense-smooth-open}.
Thus the smooth locus $U \subset X$ of the morphism $X \to \Spec(A)$
is open (by Morphisms, Definition \ref{morphisms-definition-smooth})
and is dense in the generic fibre. This reduces us to the situation
of the following paragraph.

\medskip\noindent
Assume $X$ is normal and the smooth locus $U \subset X$ of $X \to \Spec(A)$
is dense in the generic fibre. This implies that $U$ is dense in all but
finitely many fibres, see Lemma \ref{lemma-nowhere-dense-generic-fibre}.
Let $x_1, \ldots, x_r \in X \setminus U$ be the finitely many generic
points of irreducible components of $X \setminus U$ which are moreover
generic points of irreducible components of fibres of $X \to \Spec(A)$.
Set $\mathcal{O}_i = \mathcal{O}_{X, x_i}$. Observe that the fraction
field of $\mathcal{O}_i$ is the residue field of a generic point of $X$.
Let $A_i$ be the localization of $A$ at the maximal ideal corresponding
to the image of $x_i$ in $\Spec(A)$. We may apply More on Algebra, Lemma
\ref{more-algebra-lemma-epp-essentially-finite-type-separable}
and we find finite separable extensions $K_i/K$ which are
solutions for $A_i \to \mathcal{O}_i$. Let $L/K$ be a finite
separable extension dominating all of the extensions $K_i/K$.
Then $L/K$ is still a solution for $A_i \to \mathcal{O}_i$ by
More on Algebra, Lemma \ref{more-algebra-lemma-solution-goes-up}.

\medskip\noindent
Consider the diagram (\ref{equation-normalized-base-change})
with the extension $L/K$ we just produced. Note that $U_B \subset X_B$
is smooth over $B$, hence normal (for example use
Algebra, Lemma \ref{algebra-lemma-normal-goes-up}).
Thus $Y \to X_B$ is an isomorphism over $U_B$.
Let $y \in Y$ be a generic point of an irreducible
component of a fibre of $Y \to \Spec(B)$ lying over the maximal
ideal $\mathfrak m \subset B$. Assume that $y \not \in U_B$.
Then $y$ maps to one of the points $x_i$. It follows that
$\mathcal{O}_{Y, y}$ is a local ring of the integral closure
of $\mathcal{O}_i$ in $R(X) \otimes_K L$ (details omitted).
Hence because $L/K$ is a solution for
$A_i \to \mathcal{O}_i$ we see that
$B_\mathfrak m \to \mathcal{O}_{Y, y}$ is formally smooth
(this is the definition of being a "solution").
In other words, $\mathfrak m\mathcal{O}_{Y, y} = \mathfrak m_y$
and the residue field extension is separable. Hence the local ring
of the fibre at $y$ is $\kappa(y)$.
This implies the fibre is smooth over $\kappa(\mathfrak m)$
at $y$ for example by Algebra, Lemma \ref{algebra-lemma-separable-smooth}.
This finishes the proof.
\end{proof}

\begin{lemma}[Variant with separable extensions over curves]
\label{lemma-normalized-base-change-with-reduced-fibre-over-curve-separable}
Let $f : X \to S$ be a flat, finite type morphism of schemes.
Assume $S$ is Nagata, integral with function field $K$, and
regular of dimension $1$. Assume the field extensions $\kappa(\eta)/K$
are separable for every generic point $\eta$ of an irreducible
component of $X$. Then there exists a finite separable extension $L/K$
such that in the diagram
$$
\xymatrix{
Y \ar[rd]_g \ar[r]_-\nu & X \times_S T \ar[d] \ar[r] & X \ar[d]_f \\
& T \ar[r] & S
}
$$
the morphism $g$ is smooth at all generic points of fibres. Here
$T$ is the normalization of $S$ in $\Spec(L)$ and $\nu : Y \to X \times_S T$
is the normalization.
\end{lemma}

\begin{proof}
This follows from
Lemma \ref{lemma-normalized-base-change-with-reduced-fibre-separable}
in exactly the same manner that
Lemma \ref{lemma-normalized-base-change-with-reduced-fibre-over-curve}
follows from
Theorem \ref{theorem-normalized-base-change-with-reduced-fibre}.
\end{proof}








\section{Ind-quasi-affine morphisms}
\label{section-ind-quasi-affine}

\noindent
A bit of theory to be used later.

\begin{definition}
\label{definition-ind-quasi-affine}
A scheme $X$ is {\it ind-quasi-affine} if every quasi-compact open of
$X$ is quasi-affine. Similarly, a morphism of schemes $X \to Y$
is {\it ind-quasi-affine} if $f^{-1}(V)$ is ind-quasi-affine
for each affine open $V$ in $Y$.
\end{definition}

\noindent
An example of an ind-quasi-affine scheme is an open of an affine scheme.
If $X = \bigcup_{i \in I} U_i$ is a union of quasi-affine opens such that
any two $U_i$ are contained in a third, then $X$ is ind-quasi-affine.
An ind-quasi-affine scheme $X$ is separated because any two affine
opens $U, V$ are contained in a separated open subscheme of $X$, namely
$U \cup V$. Similarly an ind-quasi-affine morphism is separated.

\begin{lemma}
\label{lemma-ind-quasi-affine-alternative-definition}
For a morphism of schemes $f : X \to Y$, the following are equivalent:
\begin{enumerate}
\item $f$ is ind-quasi-affine,
\item for every affine open subscheme $V \subset Y$ and
every quasi-compact open subscheme $U \subset f^{-1}(V)$,
the induced morphism $U \to V$ is quasi-affine. 
\item
for some cover $\{ V_j \}_{j \in J}$ of $Y$ by
quasi-compact and quasi-separated open subschemes
$V_j \subset Y$, every $j \in J$, and every quasi-compact
open subscheme $U \subset f^{-1}(V_j)$, the induced morphism
$U \to V_j$ is quasi-affine.
\item for every quasi-compact and quasi-separated open subscheme
$V \subset Y$ and every quasi-compact open subscheme
$U \subset f^{-1}(V)$, the induced morphism $U \to V$ is quasi-affine.
\end{enumerate}
In particular, the property of being an ind-quasi-affine morphism
is Zariski local on the base.
\end{lemma}

\begin{proof}
The equivalence (1) $\Leftrightarrow$ (2)
follows from the definitions and
Morphisms, Lemma \ref{morphisms-lemma-characterize-quasi-affine}.
For (2) $\Rightarrow$ (4), let $U$ and $V$ be as in (4). By
Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}, the
induced morphism $U \to V$ is quasi-compact. Thus, for every affine
open $V' \subset V$, the fiber product $V' \times_V U$ is quasi-compact,
so, by (2), the induced map $V' \times_V U \to V'$ is quasi-affine.
Thus, $U \to V$ is also quasi-affine by
Morphisms, Lemma \ref{morphisms-lemma-characterize-quasi-affine}.
This argument also gives (3) $\Rightarrow$ (4): indeed, keeping the
same notation, those affine opens $V' \subset V$ that lie in one
of the $V_j$ cover $V$, so one needs to argue that the
quasi-compact map $V' \times_V U \to V'$ is quasi-affine.
However, by (3), the composition $V' \times_V U \to V' \to V_j$
is quasi-affine and, by
Schemes, Lemma \ref{schemes-lemma-compose-after-separated}, the map
$V' \to V_j$ is quasi-separated. Thus, $V' \times_V U \to V'$
is quasi-affine by
Morphisms, Lemma \ref{morphisms-lemma-quasi-affine-permanence}.
The final implications (4) $\Rightarrow$ (2) and (4) $\Rightarrow$ (3)
are evident.
\end{proof}

\begin{lemma}
\label{lemma-ind-quasi-affine-composition}
The property of being an ind-quasi-affine morphism is stable under composition.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ and $g : Y \to Z$ be ind-quasi-affine morphisms.
Let $V \subset Z$ and $U \subset f^{-1}(g^{-1}(V))$ be quasi-compact
opens such that $V$ is also quasi-separated. The image $f(U)$ is a
quasi-compact subset of $g^{-1}(V)$, so it is contained in some
quasi-compact open $W \subset g^{-1}(V)$ (a union of finitely many affines).
We obtain a factorization $U \to W \to V$. The map $W \to V$ is quasi-affine
by Lemma \ref{lemma-ind-quasi-affine-alternative-definition}, so, in
particular, $W$ is quasi-separated. Then, by
Lemma \ref{lemma-ind-quasi-affine-alternative-definition} again, $U \to W$
is quasi-affine as well. Consequently, by Morphisms,
Lemma \ref{morphisms-lemma-composition-quasi-affine}, the composition
$U \to V$ is also quasi-affine, and it remains to apply
Lemma \ref{lemma-ind-quasi-affine-alternative-definition} once more.
\end{proof}

\begin{lemma}
\label{lemma-ind-quasi-affine-examples}
Any quasi-affine morphism is ind-quasi-affine.
Any immersion is ind-quasi-affine.
\end{lemma}

\begin{proof}
The first assertion is immediate from the definitions.
In particular, affine morphisms, such as closed immersions,
are ind-quasi-affine. Thus, by
Lemma \ref{lemma-ind-quasi-affine-composition}, it remains
to show that an open immersion is ind-quasi-affine.
This, however, is immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-ind-quasi-affine-permanence}
If $f : X \to Y$ and $g : Y \to Z$ are morphisms of schemes
such that $g \circ f$ is ind-quasi-affine, then $f$ is ind-quasi-affine.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-ind-quasi-affine-alternative-definition}, we may
work Zariski locally on $Z$ and then on $Y$, so we lose no generality
by assuming that $Z$, and then also $Y$, is affine. Then any quasi-compact
open of $X$ is quasi-affine, so
Lemma \ref{lemma-ind-quasi-affine-alternative-definition} gives the claim.
\end{proof}

\begin{lemma}
\label{lemma-base-change-ind-quasi-affine}
The property of being ind-quasi-affine is stable under base change.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ be an ind-quasi-affine morphism.
For checking that every base change of $f$ is ind-quasi-affine, by
Lemma \ref{lemma-ind-quasi-affine-alternative-definition}, we may work
Zariski locally on $Y$, so we assume that $Y$ is affine.
Furthermore, we may also assume that in the base change morphism
$Z \to Y$ the scheme $Z$ is affine, too. The base change
$X \times_Y Z \to X$ is an affine morphism, so, by
Lemmas \ref{lemma-ind-quasi-affine-composition} and
\ref{lemma-ind-quasi-affine-examples},
the map $X \times_Y Z \to Y$ is ind-quasi-affine. Then, by
Lemma \ref{lemma-ind-quasi-affine-permanence}, the
base change $X \times_Y Z \to Z$ is ind-quasi-affine, as desired.
\end{proof}

\begin{lemma}
\label{lemma-descending-property-ind-quasi-affine}
The property of being ind-quasi-affine is fpqc local on the base.
\end{lemma}

\begin{proof}
The stability of ind-quasi-affineness under base change
supplied by Lemma \ref{lemma-base-change-ind-quasi-affine}
gives one direction. For the other, let $f : X \to Y$
be a morphism of schemes and let $\{g_i : Y_i \to Y\}$
be an fpqc covering such that the base change $f_i : X_i \to Y_i$
is ind-quasi-affine for all $i$. We need to show $f$ is ind-quasi-affine.

\medskip\noindent
By Lemma \ref{lemma-ind-quasi-affine-alternative-definition}, we may work
Zariski locally on $Y$, so we assume that $Y$ is affine.
Then we use stability under base change ensured by
Lemma \ref{lemma-base-change-ind-quasi-affine} to refine the cover
and assume that it is given by a single affine, faithfully flat morphism
$g : Y' \to Y$. For any quasi-compact open $U \subset X$, its
$Y'$-base change $U \times_Y Y' \subset X \times_Y Y'$ is also quasi-compact.
It remains to observe that, by
Descent, Lemma \ref{descent-lemma-descending-property-quasi-affine},
the map $U \to Y$ is quasi-affine if and only if so is $U \times_Y Y' \to Y'$.
\end{proof}

\begin{lemma}
\label{lemma-etale-separated-ind-quasi-affine}
A separated locally quasi-finite morphism of schemes is ind-quasi-affine.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ be a separated locally quasi-finite morphism of schemes.
Let $V \subset Y$ be affine and $U \subset f^{-1}(V)$ quasi-compact
open. We have to show $U$ is quasi-affine. Since $U \to V$ is a
separated quasi-finite morphism of schemes, this follows from
Zariski's Main Theorem. See
Lemma \ref{lemma-quasi-finite-separated-quasi-affine}.
\end{proof}




\section{Pushouts in the category of schemes, II}
\label{section-pushouts-II}

\noindent
This section is a continuation of Section \ref{section-pushouts}.
In this section we construct pushouts of $Y \leftarrow Z \rightarrow X$
where $Z \to X$ is a closed immersion and $Z \to Y$ is integral and
an additional condition is satisfied.
Please see the detailed discussion in \cite{Ferrand-Conducteur}.

\begin{situation}
\label{situation-pushout-along-closed-immersion-and-integral}
Here $S$ is a scheme and $i : Z \to X$ and $j : Z \to Y$
are morphisms of schemes over $S$. We assume
\begin{enumerate}
\item $i$ is a closed immersion,
\item $j$ is an integral morphism of schemes,
\item for $y \in Y$ there exists an affine open $U \subset X$
with $j^{-1}(\{y\}) \subset i^{-1}(U)$.
\end{enumerate}
\end{situation}

\begin{lemma}
\label{lemma-prepare-pushout-along-closed-immersion-and-integral}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}
then for $y \in Y$ there exist affine opens $U \subset X$ and
$V \subset Y$ with $i^{-1}(U) = j^{-1}(V)$ and $y \in V$.
\end{lemma}

\begin{proof}
Let $y \in Y$. Choose an affine open $U \subset X$
such that $j^{-1}(\{y\}) \subset i^{-1}(U)$ (possible by assumption).
Choose an affine open $V \subset Y$ neighbourhood of $y$
such that $j^{-1}(V) \subset i^{-1}(U)$.
This is possible because $j : Z \to Y$ is a closed morphism
(Morphisms, Lemma \ref{morphisms-lemma-integral-universally-closed}) and
$i^{-1}(U)$ contains the fibre over $y$.
Since $j$ is integral, the scheme theoretic fibre $Z_y$
is the spectrum of an algebra integral over a field.
By Limits, Lemma \ref{limits-lemma-ample-profinite-set-in-principal-affine}
we can find an $\overline{f} \in \Gamma(i^{-1}(U), \mathcal{O}_{i^{-1}(U)})$
such that $Z_y \subset D(\overline{f}) \subset j^{-1}(V)$.
Since $i|_{i^{-1}(U)} : i^{-1}(U) \to U$ is a closed immersion
of affines, we can choose an $f \in \Gamma(U, \mathcal{O}_U)$
whose restriction to $i^{-1}(U)$ is $\overline{f}$.
After replacing $U$ by the principal open $D(f) \subset U$
we find affine opens $y \in V \subset Y$ and $U \subset X$ with
$$
j^{-1}(\{y\}) \subset i^{-1}(U) \subset j^{-1}(V)
$$
Now we (in some sense) repeat the argument. Namely, we choose
$g \in \Gamma(V, \mathcal{O}_V)$ such that $y \in D(g)$ and
$j^{-1}(D(g)) \subset i^{-1}(U)$ (possible by the same argument
as above). Then we can pick $f \in \Gamma(U, \mathcal{O}_U)$
whose restriction to $i^{-1}(U)$ is the pullback of $g$
by $i^{-1}(U) \to V$ (again possible by the same reason as above).
Then we finally have affine opens $y \in V' = D(g) \subset V \subset Y$
and $U' = D(f) \subset U \subset X$ with $j^{-1}(V') = i^{-1}(V')$.
\end{proof}

\begin{proposition}
\label{proposition-pushout-along-closed-immersion-and-integral}
\begin{reference}
\cite[Theorem 7.1 part iii]{Ferrand-Conducteur}
\end{reference}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}
the pushout $Y \amalg_Z X$ exists in the category of schemes. Picture
$$
\xymatrix{
Z \ar[r]_i \ar[d]_j & X \ar[d]^a \\
Y \ar[r]^-b & Y \amalg_Z X
}
$$
The diagram is a fibre square, the morphism $a$ is integral,
the morphism $b$ is a closed immersion, and
$$
\mathcal{O}_{Y \amalg_Z X} =
b_*\mathcal{O}_Y \times_{c_*\mathcal{O}_Z} a_*\mathcal{O}_X
$$
as sheaves of rings where $c = a \circ i = b \circ j$.
\end{proposition}

\begin{proof}
As a topological space we set $Y \amalg_Z X$ equal to the pushout of
the diagram in the category of topological spaces (Topology, Section
\ref{topology-section-colimits}). This is just the pushout
of the underlying sets (Topology, Lemma \ref{topology-lemma-colimits})
endowed with the quotient topology.
On $Y \amalg_Z X$ we have the maps of sheaves of rings
$$
b_*\mathcal{O}_Y \longrightarrow c_*\mathcal{O}_Z
\longleftarrow a_*\mathcal{O}_X
$$
and we can define
$$
\mathcal{O}_{Y \amalg_Z X} =
b_*\mathcal{O}_Y \times_{c_*\mathcal{O}_Z} a_*\mathcal{O}_X
$$
as the fibre product in the category of sheaves of rings. To prove that we
obtain a scheme we have to show that every point has an
affine open neighbourhood. This is clear for points not in the image of $c$
as the image of $c$ is a closed subset whose complement is
isomorphic as a ringed space to $(Y \setminus j(Z)) \amalg (X \setminus i(Z))$.

\medskip\noindent
A point in the image of $c$ corresponds to a unique $y \in Y$
in the image of $j$. By
Lemma \ref{lemma-prepare-pushout-along-closed-immersion-and-integral}
we find affine opens $U \subset X$ and $V \subset Y$ with
$y \in V$ and $i^{-1}(U) = j^{-1}(V)$.
Since the construction of the first paragraph is clearly compatible
with restriction to compatible open subschemes, to prove that it
produces a scheme we may assume $X$, $Y$, and $Z$ are affine.

\medskip\noindent
If $X = \Spec(A)$, $Y = \Spec(B)$, and $Z = \Spec(C)$ are affine, then
More on Algebra, Lemma \ref{more-algebra-lemma-points-of-fibre-product}
shows that $Y \amalg_Z X = \Spec(B \times_C A)$ as topological spaces.
To finish the proof that $Y \times_Z X$ is a scheme, it suffices to show
that on $\Spec(B \times_C A)$ the structure sheaf is the fibre product
of the pushforwards. This follows by applying
More on Algebra, Lemma \ref{more-algebra-lemma-diagram-localize}
to principal affine opens of $\Spec(B \times_C A)$.

\medskip\noindent
The discussion above shows the scheme $Y \amalg_X Z$
has an affine open covering $Y \amalg_X Z = \bigcup W_i$
such that $U_i = a^{-1}(W_i)$, $V_i = b^{-1}(W_i)$, and
$\Omega_i = c^{-1}(W_i)$ are affine open in $X$, $Y$, and $Z$.
Thus $a$ and $b$ are affine.
Moreover, if $A_i$, $B_i$, $C_i$ are the rings corresponding to
$U_i$, $V_i$, $\Omega_i$, then $A_i \to C_i$ is surjective and
$W_i$ corresponds to $A_i \times_{C_i} B_i$ which surjects onto
$B_i$. Hence $b$ is a closed immersion.
The ring map $A_i \times_{C_i} B_i \to A_i$ is integral by
More on Algebra, Lemma \ref{more-algebra-lemma-fibre-product-integral}
hence $a$ is integral. The diagram is cartesian because
$$
C_i \cong B_i \otimes_{B_i \times_{C_i} A_i} A_i
$$
This follows as $B_i \times_{C_i} A_i \to B_i$
and $A_i \to C_i$ are surjective maps whose kernels are the same.

\medskip\noindent
Finally, we can apply Lemmas \ref{lemma-basic-example-pushout} and
\ref{lemma-pushout-fpqc-local} to conclude our construction is a pushout
in the category of schemes.
\end{proof}

\begin{lemma}
\label{lemma-pushout-separated}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}.
If $X$ and $Y$ are separated, then the pushout $Y \amalg_Z X$
(Proposition \ref{proposition-pushout-along-closed-immersion-and-integral})
is separated. Same with ``separated over $S$'', ``quasi-separated'', and
``quasi-separated over $S$''.
\end{lemma}

\begin{proof}
The morphism $Y \amalg X \to Y \amalg_Z X$ is surjective
and universall closed. Thus we may apply
Morphisms, Lemma \ref{morphisms-lemma-image-universally-closed-separated}.
\end{proof}

\begin{lemma}
\label{lemma-pushout-finite-type}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}
assume $S$ is a locally Noetherian scheme and $X$, $Y$, and $Z$
are locally of finite type over $S$. Then the pushout $Y \amalg_Z X$
(Proposition \ref{proposition-pushout-along-closed-immersion-and-integral})
is locally of finite type over $S$.
\end{lemma}

\begin{proof}
Looking on affine opens we recover the result of
More on Algebra, Lemma \ref{more-algebra-lemma-fibre-product-finite-type}.
\end{proof}

\begin{lemma}
\label{lemma-pushout-functor}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}
suppose given a commutative diagram
$$
\xymatrix{
Y' \ar[d]^g & Z' \ar[l]^{j'} \ar[r]_{i'} \ar[d]^h & X' \ar[d]^f \\
Y & Z \ar[l] \ar[r] & X
}
$$
with cartesian squares and $f, g, h$ separated and locally quasi-finite. Then
\begin{enumerate}
\item the pushouts $Y \amalg_Z X$ and $Y' \amalg_{Z'} X'$ exist,
\item $Y' \amalg_{Z'} X' \to Y \amalg_Z X$ is
separated and locally quasi-finite, and
\item the squares
$$
\xymatrix{
Y' \ar[r] \ar[d] & Y' \amalg_{Z'} X' \ar[d] & X' \ar[l] \ar[d] \\
Y \ar[r] & Y \amalg_Z X & X \ar[l]
}
$$
are cartesian.
\end{enumerate}
\end{lemma}

\begin{proof}
The pushout $Y \amalg_Z X$ exists by
Proposition \ref{proposition-pushout-along-closed-immersion-and-integral}.
To see that the pushout $Y' \amalg_{Z'} X'$ exists, we check
condition (3) of
Situation \ref{situation-pushout-along-closed-immersion-and-integral}
holds for $(X', Y', Z', i', j')$.
Namely, let $y' \in Y'$ and denote $y \in Y$ the image.
Choose $U \subset X$ affine open with $i(j^{-1}(y)) \subset U$.
Choose a quasi-compact open $U' \subset X'$ contained in
$f^{-1}(U)$ containing the quasi-compact subset $i'((j')^{-1}(\{y'\}))$.
By Lemma \ref{lemma-etale-separated-ind-quasi-affine}
we see that $U'$ is quasi-affine. Since $Z'_{y'}$ is the spectrum
of an algebra integral over a field, we can apply
Limits, Lemma \ref{limits-lemma-ample-profinite-set-in-principal-affine}
and we find there exists an affine open subscheme of $U'$ containing
$i'((j')^{-1}(\{y'\}))$ as desired.

\medskip\noindent
Having verified existence we check the other assertions.
Affine locally we are exactly in the situation of More on Algebra, Lemma
\ref{more-algebra-lemma-properties-algebras-over-fibre-product}
with $B \to D$ and $A' \to C'$ locally quasi-finite\footnote{To be precise
$X, Y, Z, Y \amalg_Z X, X', Y', Z', Y' \amalg_{Z'} X'$
correspond to $A', B, A, B', C', D, C, D'$.}.
In particular, the morphism $Y' \amalg_{Z'} X' \to Y \amalg_Z X$ is locally
of finite type. The squares in of the diagram are cartesian by
More on Algebra, Lemma \ref{more-algebra-lemma-module-over-fibre-product}.
Since being locally quasi-finite can be checked on fibres
(Morphisms, Lemma \ref{morphisms-lemma-quasi-finite-at-point-characterize})
we conclude that $Y' \amalg_{Z'} X' \to Y \amalg_Z X$
is locally quasi-finite.

\medskip\noindent
We still have to check $Y' \amalg_{Z'} X' \to Y \amalg_Z X$ is separated.
Observe that $Y' \amalg X' \to Y' \amalg_{Z'} X'$ is universally closed
and surjective by 
Proposition \ref{proposition-pushout-along-closed-immersion-and-integral}.
Since also the morphism $Y' \amalg X' \to Y \amalg_Z X$ is separated
(as it factors as $Y' \amalg X' \to Y \amalg X \to Y \amalg_Z X$)
we conclude by
Morphisms, Lemma \ref{morphisms-lemma-image-universally-closed-separated}.
\end{proof}

\begin{lemma}
\label{lemma-pushout-functor-equivalence-flat}
In Situation \ref{situation-pushout-along-closed-immersion-and-integral}
the category of schemes flat, separated, and locally quasi-finite
over the pushout $Y \amalg_Z X$ is equivalent to the category of
$(X', Y', Z', i', j', f, g, h)$ as in Lemma \ref{lemma-pushout-functor}
with $f, g, h$ flat. Similarly with ``flat'' replaced with
``\'etale''.
\end{lemma}

\begin{proof}
If we start with $(X', Y', Z', i', j', f, g, h)$
as in Lemma \ref{lemma-pushout-functor} with $f, g, h$ flat
or \'etale, then $Y' \amalg_{Z'} X' \to Y \amalg_Z X$ is flat
or \'etale by More on Algebra, Lemma
\ref{more-algebra-lemma-properties-algebras-over-fibre-product}.

\medskip\noindent
For the converse, let
$W \to Y \amalg_Z X$ be a separated and locally quasi-finite morphism.
Set $X' = W \times_{Y \amalg_Z X} X$, $Y' = W \times_{Y \amalg_Z X} Y$, and
$Z' = W \times_{Y \amalg_Z X} Z$ with obvious morphisms $i', j', f, g, h$.
Form the pushout $Y' \amalg_{Z'} X'$. We obtain a morphism
$$
Y' \amalg_{Z'} X' \longrightarrow W
$$
of schemes over $Y \amalg_X Z$ by the universal property of the
pushout. If we do not assume that $W \to Y \amalg_Z X$ is flat,
then in general this morphism won't be an isomorphism.
(In fact, More on Algebra, Lemma
\ref{more-algebra-lemma-module-over-fibre-product-bis}
shows the displayed arrow is a closed immersion but not an isomorphism
in general.) However, if $W \to Y \times_Z X$ is flat, then
it is an isomorphism by More on Algebra, Lemma
\ref{more-algebra-lemma-properties-algebras-over-fibre-product}.
\end{proof}

\noindent
Next, we discuss existence in the case where
both morphisms are closed immersions.

\begin{lemma}
\label{lemma-pushout-along-closed-immersions}
Let $i : Z \to X$ and $j : Z \to Y$ be closed immersions of schemes.
Then the pushout $Y \amalg_Z X$ exists in the category of schemes. Picture
$$
\xymatrix{
Z \ar[r]_i \ar[d]_j & X \ar[d]^a \\
Y \ar[r]^-b & Y \amalg_Z X
}
$$
The diagram is a fibre square, the morphisms $a$ and $b$
are closed immersions, and there is a short exact sequence
$$
0 \to \mathcal{O}_{Y \amalg_Z X} \to
a_*\mathcal{O}_X \oplus b_*\mathcal{O}_Y \to
c_*\mathcal{O}_Z \to 0
$$
where $c = a \circ i = b \circ j$.
\end{lemma}

\begin{proof}
This is a special case of
Proposition \ref{proposition-pushout-along-closed-immersion-and-integral}.
Observe that hypothesis (3) in
Situation \ref{situation-pushout-along-closed-immersion-and-integral}
is immediate because
the fibres of $j$ are singletons. Finally, reverse the roles of the arrows
to conclude that both $a$ and $b$ are closed immersions.
\end{proof}

\begin{lemma}
\label{lemma-pushout-along-closed-immersions-properties-above}
Let $i : Z \to X$ and $j : Z \to Y$ be closed immersions of schemes.
Let $f : X' \to X$ and $g : Y' \to Y$ be morphisms of schemes and let
$\varphi : X' \times_{X, i} Z \to Y' \times_{Y, j} Z$
be an isomorphism of schemes over $Z$. Consider the morphism
$$
h :
X' \amalg_{X' \times_{X, i} Z, \varphi} Y'
\longrightarrow
X \amalg_Z Y
$$
Then we have
\begin{enumerate}
\item $h$ is locally of finite type if and only if $f$ and $g$ are
locally of finite type,
\item $h$ is flat if and only if $f$ and $g$ are flat,
\item $h$ is flat and locally of finite presentation if and only if
$f$ and $g$ are flat and locally of finite presentation,
\item $h$ is smooth if and only if $f$ and $g$ are smooth,
\item $h$ is \'etale if and only if $f$ and $g$ are \'etale, and
\item add more here as needed.
\end{enumerate}
\end{lemma}

\begin{proof}
We know that the pushouts exist by
Lemma \ref{lemma-pushout-along-closed-immersions}.
In particular we get the morphism $h$.
Hence we may replace all schemes in sight by
affine schemes. In this case the assertions of the lemma
are equivalent to the corresponding assertions of
More on Algebra, Lemma
\ref{more-algebra-lemma-properties-algebras-over-fibre-product}.
\end{proof}





\section{Relative morphisms}
\label{section-relative-morphisms}

\noindent
In this section we prove a representability result which we will use in
Fundamental Groups, Section \ref{pione-section-finite-etale}
to prove a result on the category of finite \'etale coverings of a scheme.
The material in this section is discussed in the correct
generality in Criteria for Representability, Section
\ref{criteria-section-relative-morphisms}.

\medskip\noindent
Let $S$ be a scheme. Let $Z$ and $X$ be schemes over $S$.
Given a scheme $T$ over $S$ we can consider morphisms
$b : T \times_S Z \to T \times_S X$ over $S$. Picture
\begin{equation}
\label{equation-hom}
\vcenter{
\xymatrix{
T \times_S Z \ar[rd] \ar[rr]_b & &
T \times_S X \ar[ld] & Z \ar[rd] & & X \ar[ld] \\
& T \ar[rrr] & & & S
}
}
\end{equation}
Of course, we can also think of $b$ as a morphism
$b : T \times_S Z \to X$ such that
$$
\xymatrix{
T \times_S Z \ar[r] \ar[d] \ar@/^1pc/[rrr]_-b &
Z \ar[rd] & & X \ar[ld] \\
T \ar[rr] & & S
}
$$
commutes. In this situation we can define a functor
\begin{equation}
\label{equation-hom-functor}
\mathit{Mor}_S(Z, X) : (\Sch/S)^{opp} \longrightarrow \textit{Sets},
\quad
T \longmapsto \{b\text{ as above}\}
\end{equation}
Here is a basic representability result.

\begin{lemma}
\label{lemma-hom-from-finite-free-into-affine}
Let $Z \to S$ and $X \to S$ be morphisms of affine schemes.
Assume $\Gamma(Z, \mathcal{O}_Z)$ is a finite free
$\Gamma(S, \mathcal{O}_S)$-module. Then $\mathit{Mor}_S(Z, X)$
is representable by an affine scheme over $S$.
\end{lemma}

\begin{proof}
Write $S = \Spec(R)$. Choose a basis $\{e_1, \ldots, e_m\}$
for $\Gamma(Z, \mathcal{O}_Z)$ over $R$. Choose a presentation
$$
\Gamma(X, \mathcal{O}_X) = R[\{x_i\}_{i \in I}]/(\{f_k\}_{k \in K}).
$$
We will denote $\overline{x}_i$ the image of $x_i$ in this quotient.
Write
$$
P = R[\{a_{ij}\}_{i \in I, 1 \leq j \leq m}].
$$
Consider the $R$-algebra map
$$
\Psi :
R[\{x_i\}_{i \in I}]
\longrightarrow
P \otimes_R \Gamma(Z, \mathcal{O}_Z), \quad
x_i \longmapsto \sum\nolimits_j a_{ij} \otimes e_j.
$$
Write $\Psi(f_k) = \sum c_{kj} \otimes e_j$ with $c_{kj} \in P$.
Finally, denote $J \subset P$ the ideal generated by the elements
$c_{kj}$, $k \in K$, $1 \leq j \leq m$. We claim that
$W = \Spec(P/J)$ represents the functor $\mathit{Mor}_S(Z, X)$.

\medskip\noindent
First, note that by construction $P/J$ is an $R$-algebra, hence
a morphism $W \to S$. Second, by construction the map
$\Psi$ factors through $\Gamma(X, \mathcal{O}_X)$, hence we obtain
an $P/J$-algebra homomorphism
$$
P/J \otimes_R \Gamma(X, \mathcal{O}_X)
\longrightarrow
P/J \otimes_R \Gamma(Z, \mathcal{O}_Z)
$$
which determines a morphism
$b_{univ} : W \times_S Z \to W \times_S X$.
By the Yoneda lemma $b_{univ}$ determines a
transformation of functors $W \to \mathit{Mor}_S(Z, X)$ which we
claim is an isomorphism. To show that it is an isomorphism it suffices
to show that it induces a bijection of sets
$W(T) \to \mathit{Mor}_S(Z, X)(T)$ over any affine
scheme $T$.

\medskip\noindent
Suppose $T = \Spec(R')$ is an affine scheme over $S$
and $b \in \mathit{Mor}_S(Z, X)(T)$. The structure morphism $T \to S$
defines an $R$-algebra structure on $R'$ and $b$ defines an $R'$-algebra map
$$
b^\sharp :
R' \otimes_R \Gamma(X, \mathcal{O}_X)
\longrightarrow
R' \otimes_R \Gamma(Z, \mathcal{O}_Z).
$$
In particular we can write
$b^\sharp(1 \otimes \overline{x}_i) = \sum \alpha_{ij} \otimes e_j$
for some $\alpha_{ij} \in R'$. This corresponds to an $R$-algebra map
$P \to R'$ determined by the rule $a_{ij} \mapsto \alpha_{ij}$. This
map factors through the quotient $P/J$ by the construction of the ideal
$J$ to give a map $P/J \to R'$. This in turn corresponds to a morphism
$T \to W$ such that $b$ is the pullback of $b_{univ}$.
Some details omitted.
\end{proof}

\begin{lemma}
\label{lemma-hom-from-finite-locally-free-into-affine}
Let $Z \to S$ and $X \to S$ be morphisms of schemes.
If $Z \to S$ is finite locally free and $X \to S$ is affine,
then $\mathit{Mor}_S(Z, X)$ is representable by a scheme
affine over $S$.
\end{lemma}

\begin{proof}
Choose an affine open covering $S = \bigcup U_i$ such that
$\Gamma(Z \times_S U_i, \mathcal{O}_{Z \times_S U_i})$ is
finite free over $\mathcal{O}_S(U_i)$. Let $F_i \subset \mathit{Mor}_S(Z, X)$
be the subfunctor which assigns to $T/S$ the empty set if
$T \to S$ does not factor through $U_i$ and $\mathit{Mor}_S(Z, X)(T)$
otherwise. Then the collection of these subfunctors satisfy the conditions
(2)(a), (2)(b), (2)(c) of
Schemes, Lemma \ref{schemes-lemma-glue-functors} which proves the lemma.
Condition (2)(a) follows from
Lemma \ref{lemma-hom-from-finite-free-into-affine}
and the other two follow from straightforward arguments.
\end{proof}

\noindent
The condition on the morphism $f : X \to S$ in the lemma below is very
useful to prove statements like it. It holds if one of the following
is true: $X$ is quasi-affine, $f$ is quasi-affine, $f$ is quasi-projective,
$f$ is locally projective, there exists an ample invertible sheaf on $X$,
there exists an $f$-ample invertible sheaf on $X$, or
there exists an $f$-very ample invertible sheaf on $X$.

\begin{lemma}
\label{lemma-hom-from-finite-locally-free-representable}
Let $Z \to S$ and $X \to S$ be morphisms of schemes.
Assume
\begin{enumerate}
\item $Z \to S$ is finite locally free, and
\item for all $(s, x_1, \ldots, x_d)$ where $s \in S$ and
$x_1, \ldots, x_d \in X_s$ there exists an affine open $U \subset X$
with $x_1, \ldots, x_d \in U$.
\end{enumerate}
Then $\mathit{Mor}_S(Z, X)$ is representable by a scheme.
\end{lemma}

\begin{proof}
Consider the set $I$ of pairs $(U, V)$ where $U \subset X$ and $V \subset S$
are affine open and $U \to S$ factors through $V$. For $i \in I$ denote
$(U_i, V_i)$ the corresponding pair. Set
$F_i = \mathit{Mor}_{V_i}(Z_{V_i}, U_i)$.
It is immediate that $F_i$ is a subfunctor of $\mathit{Mor}_S(Z, X)$.
Then we claim that conditions
(2)(a), (2)(b), (2)(c) of
Schemes, Lemma \ref{schemes-lemma-glue-functors} which proves the lemma.

\medskip\noindent
Condition (2)(a) follows from
Lemma \ref{lemma-hom-from-finite-locally-free-into-affine}.

\medskip\noindent
To check condition (2)(b) consider $T/S$ and $b \in \mathit{Mor}_S(Z, X)$.
Thinking of $b$ as a morphism $T \times_S Z \to X$ we find an open
$b^{-1}(U_i) \subset T \times_S Z$. Clearly, $b \in F_i(T)$
if and only if $b^{-1}(U_i) = T \times_S Z$. Since the projection
$p : T \times_S Z \to T$ is finite hence closed, the set
$U_{i, b} \subset T$ of points $t \in T$ with
$p^{-1}(\{t\}) \subset b^{-1}(U_i)$ is open.
Then $f : T' \to T$ factors through $U_{i, b}$ if and only
if $b \circ f \in F_i(T')$ and we are done checking (2)(b).

\medskip\noindent
Finally, we check condition (2)(c) and this is where our condition
on $X \to S$ is used. Namely, consider
$T/S$ and $b \in \mathit{Mor}_S(Z, X)$.
It suffices to prove that every $t \in T$
is contained in one of the opens $U_{i, b}$ defined
in the previous paragraph.
This is equivalent to the condition that
$b(p^{-1}(\{t\})) \subset U_i$ for some $i$
where $p : T \times_S Z \to T$ is the projection and
$b : T \times_S Z \to X$ is the given morphism.
Since $p$ is finite, the set $b(p^{-1}(\{t\})) \subset X$
is finite and contained in the fibre of $X \to S$ over
the image $s$ of $t$ in $S$.
Thus our condition on $X \to S$ exactly shows a
suitable pair exists.
\end{proof}

\begin{lemma}
\label{lemma-hom-from-finite-locally-free-separated-lqf}
Let $Z \to S$ and $X \to S$ be morphisms of schemes.
Assume $Z \to S$ is finite locally free and $X \to S$
is separated and locally quasi-finite.
Then $\mathit{Mor}_S(Z, X)$ is representable by a scheme.
\end{lemma}

\begin{proof}
This follows from
Lemmas \ref{lemma-hom-from-finite-locally-free-representable} and
\ref{lemma-separated-locally-quasi-finite-over-affine}.
\end{proof}









\section{Characterizing pseudo-coherent complexes, III}
\label{section-characterize-pseudo-coherent}

\noindent
In this section we discuss characterizations of pseudo-coherent complexes
in terms of cohomology. This is a continuation of
Derived Categories of Schemes, Section
\ref{perfect-section-pseudo-coherent}.
A basic tool will be to reduce to the case of projective space
using a derived version of Chow's lemma, see Lemma \ref{lemma-derived-chow}.

\begin{lemma}
\label{lemma-case-of-tor-independence}
Consider a commutative diagram of schemes
$$
\xymatrix{
Z' \ar[d] \ar[r] & Y' \ar[d] \\
X' \ar[r] & S'
}
$$
Let $S \to S'$ be a morphism. Denote by $X$ and $Y$ the base
changes of $X'$ and $Y'$ to $S$.
Assume $Y' \to S'$ and $Z' \to X'$ are flat.
Then $X \times_S Y$ and $Z'$ are Tor independent over $X' \times_{S'} Y'$.
\end{lemma}

\begin{proof}
The question is local, hence we may assume all schemes are affine
(some details omitted). Observe that
$$
\xymatrix{
X \times_S Y \ar[r] \ar[d] & X' \times_{S'} Y' \ar[d] \\
X \ar[r] & X'
}
$$
is cartesian with flat vertical arrows.
Write $X = \Spec(A)$, $X' = \Spec(A')$,
$X' \times_{S'} Y' = \Spec(B')$. Then
$X \times_S Y = \Spec(A \otimes_{A'} B')$.
Write $Z' = \Spec(C')$. We have to show
$$
\text{Tor}_p^{B'}(A \otimes_{A'} B', C') = 0,
\quad\text{for } p > 0
$$
Since $A' \to B'$ is flat
we have $A \otimes_{A'} B' = A \otimes_{A'}^\mathbf{L} B'$.
Hence
$$
(A \otimes_{A'} B') \otimes_{B'}^\mathbf{L} C' =
(A \otimes_{A'}^\mathbf{L} B') \otimes_{B'}^\mathbf{L} C' =
A \otimes_{A'}^\mathbf{L} C' =
A \otimes_{A'} C'
$$
The second equality by More on Algebra, Lemma
\ref{more-algebra-lemma-double-base-change}.
The last equality because $A' \to C'$ is flat. This proves the lemma.
\end{proof}

\begin{lemma}[Derived Chow's lemma]
\label{lemma-derived-chow}
Let $A$ be a ring. Let $X$ be a separated scheme of finite presentation
over $A$. Let $x \in X$. Then there exist
an open neighbourhood $U \subset X$ of $x$,
an $n \geq 0$,
an open $V \subset \mathbf{P}^n_A$,
a closed subscheme $Z \subset X \times_A \mathbf{P}^n_A$,
a point $z \in Z$, and
an object $E$ in $D(\mathcal{O}_{X \times_A \mathbf{P}^n_A})$ such that
\begin{enumerate}
\item $Z \to X \times_A \mathbf{P}^n_A$ is of finite presentation,
\item $b : Z \to X$ is an isomorphism over $U$ and $b(z) = x$,
\item $c : Z \to \mathbf{P}^n_A$ is a closed immersion over $V$,
\item $b^{-1}(U) = c^{-1}(V)$, in particular $c(z) \in V$,
\item $E|_{X \times_A V} \cong
(b, c)_*\mathcal{O}_Z|_{X \times_A V}$,
\item $E$ is pseudo-coherent and supported on $Z$.
\end{enumerate}
\end{lemma}

\begin{proof}
We can find a finite type $\mathbf{Z}$-subalgebra $A' \subset A$
and a scheme $X'$ separated and of finite presentation over $A'$
whose base change to $A$ is $X$. See
Limits, Lemmas \ref{limits-lemma-descend-finite-presentation} and
\ref{limits-lemma-descend-separated-finite-presentation}.
Let $x' \in X'$ be the image of $x$.
If we can prove the lemma for $x' \in X'/A'$, then
the lemma follows for $x \in X/A$.
Namely, if $U', n', V', Z', z', E'$ provide the solution
for $x' \in X'/A'$, then we can let
$U \subset X$ be the inverse image of $U'$,
let $n = n'$,
let $V \subset \mathbf{P}^n_A$ be the inverse image of $V'$,
let $Z \subset X \times \mathbf{P}^n$ be
the scheme theoretic inverse image of $Z'$,
let $z \in Z$ be the unique point mapping to $x$, and
let $E$ be the derived pullback of $E'$.
Observe that $E$ is pseudo-coherent by
Cohomology, Lemma \ref{cohomology-lemma-pseudo-coherent-pullback}.
It only remains to check (5). To see this
set $W = b^{-1}(U) = c^{-1}(V)$ and $W' = (b')^{-1}(U) = (c')^{-1}(V')$ 
and consider the cartesian square
$$
\xymatrix{
W \ar[d]_{(b, c)} \ar[r] & W' \ar[d]^{(b', c')} \\
X \times_A V \ar[r] & X' \times_{A'} V'
}
$$
By Lemma \ref{lemma-case-of-tor-independence} the schemes
$X \times_A V$ and $W'$ are Tor independent over $X' \times_{A'} V'$.
Hence the derived pullback of
$(b', c')_*\mathcal{O}_{W'}$ to $X \times_A V$
is $(b, c)_*\mathcal{O}_W$ by
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-compare-base-change}.
This also uses that $R(b', c')_*\mathcal{O}_{Z'} = (b', c')_*\mathcal{O}_{Z'}$
because $(b', c')$ is a closed immersion and simiarly for
$(b, c)_*\mathcal{O}_Z$.
Since $E'|_{U' \times_{A'} V'} =
(b', c')_*\mathcal{O}_{W'}$ we obtain
$E|_{U \times_A V} = (b, c)_*\mathcal{O}_W$
and (5) holds.
This reduces us to the situation described in the next
paragraph.

\medskip\noindent
Assume $A$ is of finite type over $\mathbf{Z}$.
Choose an affine open neighbourhood $U \subset X$ of $x$.
Then $U$ is of finite type over $A$.
Choose a closed immersion $U \to \mathbf{A}^n_A$ and denote
$j : U \to \mathbf{P}^n_A$ the immersion we get by composing
with the open immersion $\mathbf{A}^n_A \to \mathbf{P}^n_A$.
Let $Z$ be the scheme theoretic closure of
$$
(\text{id}_U, j) : U \longrightarrow X \times_A \mathbf{P}^n_A
$$
Since the projection $X \times \mathbf{P}^n \to X$ is separated,
we conclude from Morphisms, Lemma
\ref{morphisms-lemma-scheme-theoretic-image-of-partial-section}
that $b : Z \to X$ is an isomorphism over $U$.
Let $z \in Z$ be the unique point lying over $x$.

\medskip\noindent
Let $Y \subset \mathbf{P}^n_A$ be the scheme theoretic
closure of $j$. Then it is clear that $Z \subset X \times_A Y$
is the scheme theoretic closure of
$(\text{id}_U, j) : U \to X \times_A Y$.
As $X$ is separated, the morphism
$X \times_A Y \to Y$ is separated as well.
Hence we see that $Z \to Y$ is an isomorphism over
the open subscheme $j(U) \subset Y$ by the same lemma we used above.
Choose $V \subset \mathbf{P}^n_A$ open with $V \cap Y = j(U)$.
Then we see that (3) and (4) hold.

\medskip\noindent
Because $A$ is Noetherian we see that $X$ and $X \times_A \mathbf{P}^n_A$
are Noetherian schemes. Hence we can take $E = (b, c)_*\mathcal{O}_Z$
in this case, see Derived Categories of Schemes, Lemma
\ref{perfect-lemma-identify-pseudo-coherent-noetherian}.
This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-compute-Fourier-Mukai-for-derived-chow}
Let $A$, $x \in X$, and
$U, n, V, Z, z, E$ be as in Lemma \ref{lemma-derived-chow}.
For any $K \in D_\QCoh(\mathcal{O}_X)$ we have
$$
Rq_*(Lp^*K \otimes^\mathbf{L} E)|_V = R(U \to V)_*K|_U
$$
where $p : X \times_A \mathbf{P}^n_A \to X$ and
$q : X \times_A \mathbf{P}^n_A \to \mathbf{P}^n_A$ are
the projections and where the morphism $U \to V$ is
the finitely presented closed immersion $c \circ (b|_U)^{-1}$.
\end{lemma}

\begin{proof}
Since $b^{-1}(U) = c^{-1}(V)$ and since $c$ is a closed immersion
over $V$, we see that $c \circ (b|_U)^{-1}$ is a closed immersion.
It is of finite presentation because $U$ and $V$ are of finite
presentation over $A$, see
Morphisms, Lemma \ref{morphisms-lemma-finite-presentation-permanence}.
First we have
$$
Rq_*(Lp^*K \otimes^\mathbf{L} E)|_V =
Rq'_*\left((Lp^*K \otimes^\mathbf{L} E)|_{X \times_A V}\right)
$$
where $q' : X \times_A V \to V$ is the projection because
formation of total direct image commutes with localization.
Set $W = b^{-1}(U) = c^{-1}(V)$ and denote $i : W \to X \times_A V$
the closed immersion $i = (b, c)|_W$. Then
$$
Rq'_*\left((Lp^*K \otimes^\mathbf{L} E)|_{X \times_A V}\right) =
Rq'_*(Lp^*K|_{X \times_A V} \otimes^\mathbf{L} i_*\mathcal{O}_W)
$$
by property (5). Since $i$ is a closed immersion we have
$i_*\mathcal{O}_W = Ri_*\mathcal{O}_W$.
Using
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-cohomology-base-change}
we can rewrite this as
$$
Rq'_* Ri_* Li^* Lp^*K|_{X \times_A V} =
R(q' \circ i)_* Lb^*K|_W =
R(U \to V)_* K|_U
$$
which is what we want.
\end{proof}

\begin{lemma}
\label{lemma-characterize-pseudo-coherent}
Let $A$ be a ring. Let $X$ be a scheme separated and
of finite presentation over $A$. Let $K \in D_\QCoh(\mathcal{O}_X)$.
If $R\Gamma(X, E \otimes^\mathbf{L} K)$ is pseudo-coherent
in $D(A)$ for every pseudo-coherent $E$ in $D(\mathcal{O}_X)$,
then $K$ is pseudo-coherent relative to $A$.
\end{lemma}

\begin{proof}
Assume $K \in D_\QCoh(\mathcal{O}_X)$ and
$R\Gamma(X, E \otimes^\mathbf{L} K)$ is pseudo-coherent
in $D(A)$ for every pseudo-coherent $E$ in $D(\mathcal{O}_X)$.
Let $x \in X$. We will show that $K$ is pseudo-coherent relative to $A$
in a neighbourhood of $x$ and this will prove the lemma.

\medskip\noindent
Choose $U, n, V, Z, z, E$ as in Lemma \ref{lemma-derived-chow}.
Denote $p : X \times \mathbf{P}^n \to X$ and
$q : X \times \mathbf{P}^n \to \mathbf{P}^n_A$
the projections.
Then for any $i \in \mathbf{Z}$ we have
\begin{align*}
& R\Gamma(\mathbf{P}^n_A,
Rq_*(Lp^*K \otimes^\mathbf{L} E)
\otimes^\mathbf{L}
\mathcal{O}_{\mathbf{P}^n_A}(i)) \\
& =
R\Gamma(X \times \mathbf{P}^n,
Lp^*K \otimes^\mathbf{L} E \otimes^\mathbf{L}
Lq^*\mathcal{O}_{\mathbf{P}^n_A}(i)) \\
& =
R\Gamma(X,
K \otimes^\mathbf{L} Rq_*(E \otimes^\mathbf{L}
Lq^*\mathcal{O}_{\mathbf{P}^n_A}(i)))
\end{align*}
by 
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-cohomology-base-change}.
By
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-flat-proper-pseudo-coherent-direct-image-general}
the complex $Rq_*(E \otimes^\mathbf{L} Lq^*\mathcal{O}_{\mathbf{P}^n_A}(i))$
is pseudo-coherent on $X$. Hence the assumption tells us the expression
in the displayed formula is a pseudo-coherent object of $D(A)$.
By
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-pseudo-coherent-on-projective-space}
we conclude that $Rq_*(Lp^*K \otimes^\mathbf{L} E)$ is
pseudo-coherent on $\mathbf{P}^n_A$.
By Lemma \ref{lemma-compute-Fourier-Mukai-for-derived-chow}
we have
$$
Rq_*(Lp^*K \otimes^\mathbf{L} E)|_{X \times_A V} =
R(U \to V)_*K|_U
$$
Since $U \to V$ is a closed immersion into an open subscheme of
$\mathbf{P}^n_A$ this means $K|_U$ is pseudo-coherent relative to $A$
by Lemma \ref{lemma-check-relative-pseudo-coherence-on-charts}.
\end{proof}

\begin{lemma}
\label{lemma-characterize-pseudo-coh-improved}
Let $A$ be a ring. Let $X$ be a scheme separated and
of finite presentation over $A$. Let 
$K \in D_\QCoh(\mathcal{O}_X).$ If 
$R \Gamma (X, E \otimes ^{\mathbf{L}} K)$ is
pseudo-coherent in $D(A)$ for every perfect 
$E \in D(\mathcal{O}_X)$, then $K$ is pseudo-coherent
relative to $A$.
\end{lemma}

\begin{proof}
In view of Lemma \ref{lemma-characterize-pseudo-coherent}, it suffices
to show $R \Gamma (X, E \otimes ^{\mathbf{L}} K)$ is
pseudo-coherent in $D(A)$ for every pseudo-coherent 
$E \in D(\mathcal{O}_X)$. By Derived Categories of Schemes,
Proposition \ref{perfect-proposition-detecting-bounded-above}
it follows that $K \in D^-_\QCoh (\mathcal{O}_X)$. Now the
result follows by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-perfect-enough}.
\end{proof}

\begin{lemma}
\label{lemma-characterize-relatively-perfect}
Let $A$ be a ring. Let $X$ be a scheme separated, of
finite presentation, and flat over $A$. Let 
$K \in D_\QCoh(\mathcal{O}_X).$ If 
$R \Gamma (X, E \otimes^\mathbf{L} K)$ is perfect in
$D(A)$ for every perfect $E \in D(\mathcal{O}_X)$, then $K$ is
$\Spec(A)$-perfect.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-characterize-pseudo-coh-improved},
$K$ is pseudo-coherent relative to $A$. By Lemma
\ref{lemma-check-relative-pseudo-coherence-on-charts},
$K$ is pseudo-coherent in $D( \mathcal{O}_X)$.
By Derived Categories of Schemes, Proposition
\ref{perfect-proposition-detecting-bounded-below}
we see that $K$ is in $D^-(\mathcal{O}_X)$.
Let $\mathfrak{p}$ be a prime ideal of $A$ and denote
$i : Y \to X$ the inclusion of the scheme theoretic
fibre over $\mathfrak{p}$, i.e., $Y$ is a scheme over $\kappa(\mathfrak p)$.
By Derived Categories of Schemes, Lemma \ref{perfect-lemma-bounded-on-fibres},
we will be done if we can show  $Li^*(K)$ is bounded below. 
Let $G \in D_{perf} (\mathcal{O}_X)$ be a perfect
complex which generates $D_\QCoh (\mathcal{O}_X)$,
see Derived Categories of Schemes, Theorem
\ref{perfect-theorem-bondal-van-den-Bergh}.
We have
\begin{align*}
R\Hom _{\mathcal{O}_Y}(Li^*(G), Li^*(K))
& =
R\Gamma(Y, Li^*(G ^\vee \otimes ^\mathbf{L} K)) \\
& =
R\Gamma(X, G^\vee \otimes ^{\mathbf{L}} K)
\otimes^\mathbf{L}_A \kappa(\mathfrak{p})
\end{align*}
The first equality uses that $Li^*$ preserves perfect objects and duals
and Cohomology, Lemma \ref{cohomology-lemma-dual-perfect-complex}; we omit
some details. The second equality follows from
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-compare-base-change}
as $X$ is flat over $A$. It follows from our hypothesis that this is a
perfect object of $D(\kappa(\mathfrak{p}))$. The object
$Li^*(G) \in D_{perf}(\mathcal{O}_Y)$  generates $D_\QCoh(\mathcal{O}_Y)$ by
Derived Categories of Schemes, Remark \ref{perfect-remark-pullback-generator}.
Hence Derived Categories of Schemes, Proposition
\ref{perfect-proposition-detecting-bounded-below}
now implies that $Li^*(K)$ is bounded below and we win.
\end{proof}




\section{Descent finiteness properties of complexes}
\label{section-descent-finiteness}

\noindent
This section is the continuation of Derived Categories of Schemes,
Section \ref{perfect-section-descent-finiteness}.

\begin{lemma}
\label{lemma-relative-pseudo-coherent-descends-fppf}
Let $X \to S$ be locally of finite type.
Let $\{f_i : X_i \to X\}$ be an fppf covering of schemes.
Let $E \in D_\QCoh(\mathcal{O}_X)$. Let $m \in \mathbf{Z}$.
Then $E$ is $m$-pseudo-coherent relative to $S$
if and only if each $Lf_i^*E$ is $m$-pseudo-coherent relative to $S$.
\end{lemma}

\begin{proof}
Assume $E$ is $m$-pseudo-coherent relative to $S$.
The morphisms $f_i$ are pseudo-coherent by
Lemma \ref{lemma-flat-finite-presentation-pseudo-coherent}.
Hence $Lf_i^*E$ is $m$-pseudo-coherent relative to $S$
by Lemma \ref{lemma-pull-relative-pseudo-coherent}.

\medskip\noindent
Conversely, assume that $Lf_i^*E$ is $m$-pseudo-coherent relative to $S$
for each $i$. Pick $S = \bigcup U_j$, $W_j \to U_j$,
$W_j = \bigcup W_{j, k}$, $T_{j, k} \to W_{j, k}$, and
morphisms $\alpha_{j, k} : T_{j, k} \to X_{i(j, k)}$ over $S$ as in
Lemma \ref{lemma-dominate-fppf}.
Since the morphism $T_{j, K} \to S$ is flat and of finite presentation,
we see that $\alpha_{j, k}$ is pseudo-coherent by
Lemma \ref{lemma-permanence-pseudo-coherent}.
Hence
$$
L\alpha_{j, k}^*Lf_{i(j, k)}^*E = L(T_{i, k} \to S)^*E
$$
is $m$-pseudo-coherent relative to $S$ by
Lemma \ref{lemma-pull-relative-pseudo-coherent}.
Now we want to descend this property
through the coverings $\{T_{j, k} \to W_{j, k}\}$,
$W_j = \bigcup W_{j, k}$, $\{W_j \to U_j\}$, and $S = \bigcup U_j$.
Since for Zariski coverings the result is true
(by the definition of $m$-pseudo-coherence relative to $S$),
this means we may assume we have a single surjective
finite locally free morphism $\pi : Y \to X$
such that $L\pi^*E$ is pseudo-coherent relative to $S$.
In this case $R\pi_*L\pi^*E$ is pseudo-coherent relative to $S$
by Lemma \ref{lemma-finite-morphism-relative-pseudo-coherence}
(this is the first time we use that $E$ has quasi-coherent cohomology sheaves).
We have
$R\pi_*L\pi^*E = E \otimes^\mathbf{L}_{\mathcal{O}_X} \pi_*\mathcal{O}_Y$
for example by
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-cohomology-base-change}
and locally on $X$ the map $\mathcal{O}_X \to \pi_*\mathcal{O}_Y$
is the inclusion of a direct summand. Hence we conclude by
Lemma \ref{lemma-summands-relative-pseudo-coherent}.
\end{proof}

\begin{lemma}
\label{lemma-relative-pseudo-coherent-post-compose}
Let $X \to T \to S$ be morphisms of schemes. Assume $T \to S$
is flat and locally of finite presentation and $X \to T$
locally of finite type. Let $E \in D(\mathcal{O}_X)$. Let $m \in \mathbf{Z}$.
Then $E$ is $m$-pseudo-coherent relative to $S$
if and only if $E$ is $m$-pseudo-coherent relative to $T$.
\end{lemma}

\begin{proof}
Locally on $X$ we can choose a closed immersion $i : X \to \mathbf{A}^n_T$.
Then $\mathbf{A}^n_T \to S$ is flat and locally of finite presentation.
Thus we may
apply Lemma \ref{lemma-composition-relative-pseudo-coherent}
to see the equivalence holds.
\end{proof}

\begin{lemma}
\label{lemma-relative-pseudo-coherent-descends-fppf-base}
Let $f : X \to S$ be locally of finite type.
Let $\{S_i \to S\}$ be an fppf covering of schemes.
Denote $f_i : X_i \to S_i$ the base change of $f$
and $g_i : X_i \to X$ the projection.
Let $E \in D_\QCoh(\mathcal{O}_X)$. Let $m \in \mathbf{Z}$.
Then $E$ is $m$-pseudo-coherent relative to $S$
if and only if each $Lg_i^*E$ is $m$-pseudo-coherent relative to $S_i$.
\end{lemma}

\begin{proof}
This follows formally from
Lemmas \ref{lemma-relative-pseudo-coherent-descends-fppf} and
\ref{lemma-relative-pseudo-coherent-post-compose}.
Namely, if $E$ is $m$-pseudo-coherent relative to $S$,
then $Lg_i^*E$ is $m$-pseudo-coherent relative to $S$ (by the first lemma),
hence $Lg_i^*E$ is $m$-pseudo-coherent relative to $S_i$ (by the second).
Conversely, if
$Lg_i^*E$ is $m$-pseudo-coherent relative to $S_i$, then
$Lg_i^*E$ is $m$-pseudo-coherent relative to $S$ (by the second lemma),
hence $E$ is $m$-pseudo-coherent relative to $S$ (by the first lemma).
\end{proof}






\section{Relatively perfect objects}
\label{section-relatively-perfect}

\noindent
This section is a continuation of the discussion in
Derived Categories of Schemes, Section
\ref{perfect-section-relatively-perfect}.

\begin{lemma}
\label{lemma-thickening-pseudo-coherent}
Let $i : X \to X'$ be a finite order thickening of schemes. Let
$K' \in D(\mathcal{O}_{X'})$ be an object such that
$K = Li^*K'$ is pseudo-coherent. Then $K'$ is pseudo-coherent.
\end{lemma}

\begin{proof}
We first prove $K'$ has quasi-coherent cohomology sheaves.
To do this, we may reduce to the case of a first order thickening, see
Section \ref{section-thickenings}. Let $\mathcal{I} \subset \mathcal{O}_{X'}$
be the quasi-coherent sheaf of ideals cutting out $X$.
Tensoring the short exact sequence
$$
0 \to \mathcal{I} \to \mathcal{O}_{X'} \to i_*\mathcal{O}_X \to 0
$$
with $K'$ we obtain a distinguished triangle
$$
K' \otimes_{\mathcal{O}_{X'}}^\mathbf{L} \mathcal{I}
\to K' \to
K' \otimes_{\mathcal{O}_{X'}}^\mathbf{L} i_*\mathcal{O}_X
\to
(K' \otimes_{\mathcal{O}_{X'}}^\mathbf{L} \mathcal{I})[1]
$$
Since $i_* = Ri_*$ and since we may view $\mathcal{I}$
as a quasi-coherent $\mathcal{O}_X$-module (as we have a first
order thickening) we may rewrite this as
$$
i_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{I})
\to K' \to
i_*K \to
i_*(K \otimes_{\mathcal{O}_X}^\mathbf{L} \mathcal{I})[1]
$$
Please use Cohomology, Lemma
\ref{cohomology-lemma-projection-formula-closed-immersion}
to identify the terms. Since $K$ is in
$D_\QCoh(\mathcal{O}_X)$ we conclude that
$K'$ is in $D_\QCoh(\mathcal{O}_{X'})$; this uses
Derived Categories of Schemes, Lemmas
\ref{perfect-lemma-pseudo-coherent},
\ref{perfect-lemma-quasi-coherence-tensor-product}, and
\ref{perfect-lemma-quasi-coherence-direct-image}.

\medskip\noindent
Assume $K'$ is in $D_\QCoh(\mathcal{O}_{X'})$.
The question is local on $X'$ hence we may assume $X'$ is affine.
Say $X' = \Spec(A')$ and $X = \Spec(A)$ with $A = A'/I$ and $I$ nilpotent.
Then $K'$ comes from an object $M' \in D(A')$, see
Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded}.
Thus $M = M' \otimes_{A'}^\mathbf{L} A$ is a pseudo-coherent
object of $D(A)$ by Derived Categories of Schemes,
Lemma \ref{perfect-lemma-pseudo-coherent-affine} and our assumption on $K$.
Hence we can represent $M$
by a bounded above complex of finite free $A$-modules $E^\bullet$, see
More on Algebra, Lemma \ref{more-algebra-lemma-pseudo-coherent}.
By More on Algebra, Lemma
\ref{more-algebra-lemma-lift-complex-projectives}
we conclude that $M'$ is pseudo-coherent as desired.
\end{proof}

\begin{lemma}
\label{lemma-thickening-relatively-perfect}
Consider a cartesian diagram
$$
\xymatrix{
X \ar[r]_i \ar[d]_f & X' \ar[d]^{f'} \\
Y \ar[r]^j & Y'
}
$$
of schemes. Assume $X' \to Y'$ is flat and locally
of finite presentation and $Y \to Y'$ is a finite order thickening.
Let $E' \in D(\mathcal{O}_{X'})$. If $E = Li^*(E')$ is $Y$-perfect,
then $E'$ is $Y'$-perfect.
\end{lemma}

\begin{proof}
Recall that being $Y$-perfect for $E$ means $E$ is
pseudo-coherent and locally has finite tor dimension as a complex
of $f^{-1}\mathcal{O}_Y$-modules
(Derived Categories of Schemes,
Definition \ref{perfect-definition-relatively-perfect}).
By Lemma \ref{lemma-thickening-pseudo-coherent}
we find that $E'$ is pseudo-coherent.
In particular, $E'$ is in $D_\QCoh(\mathcal{O}_{X'})$, see
Derived Categories of Schemes, Lemma \ref{perfect-lemma-pseudo-coherent}.
To prove that $E'$ locally has finite tor dimension
we may work locally on $X'$. Hence we may assume
$X'$, $S'$, $X$, $S$ are affine, say given by
rings $A'$, $R'$, $A$, $R$.
Then we reduce to the commutative algebra version by
Derived Categories of Schemes,
Lemma \ref{perfect-lemma-affine-locally-rel-perfect}.
The commutative algebra version in More on Algebra, Lemma
\ref{more-algebra-lemma-thickening-relatively-perfect}.
\end{proof}

\begin{lemma}
\label{lemma-henselian-relatively-perfect}
Let $(R, I)$ be a pair consisting of a ring and an ideal $I$
contained in the Jacobson radical. Set $S = \Spec(R)$ and $S_0 = \Spec(R/I)$.
Let $f : X \to S$ be proper, flat, and of finite presentation.
Denote $X_0 = S_0 \times_S X$. Let $E \in D(\mathcal{O}_X)$
be pseudo-coherent. If the derived restriction $E_0$ of $E$
to $X_0$ is $S_0$-perfect, then $E$ is $S$-perfect.
\end{lemma}

\begin{proof}
Choose a finite affine open covering $X = U_1 \cup \ldots \cup U_n$.
For each $i$ we can choose a closed immersion $U_i \to \mathbf{A}^{d_i}_S$.
Set $U_{i, 0} = S_0 \times_S U_i$.
For each $i$ the complex $E_0|_{U_{i, 0}}$ has tor amplitude
in $[a_i, b_i]$ for some $a_i, b_i \in \mathbf{Z}$.
Let $x \in X$ be a point.
We will show that the tor amplitude of
$E_x$ over $R$ is in $[a_i - d_i, b_i]$ for some $i$.
This will finish the proof as the tor amplitude can be
read off from the stalks by
Cohomology, Lemma \ref{cohomology-lemma-tor-amplitude-stalk}.

\medskip\noindent
Since $f$ is proper $f(\overline{\{x\}})$ is a closed subset of $S$.
Since $I$ is contained in the Jacobson radical, we see that
$f(\overline{\{x\}})$ meeting the closed subset $S_0 \subset S$.
Hence there is a specialization $x \leadsto x_0$ with $x_0 \in X_0$.
Pick an $i$ with $x_0 \in U_i$, so $x_0 \in U_{i, 0}$.
We will fix $i$ for the rest of the proof.
Write $U_i = \Spec(A)$. Then $A$ is a flat, finitely presented
$R$-algebra which is a quotient of a polynomial $R$-algebra in
$d_i$-variables. The restriction $E|_{U_i}$ corresponds
(by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-affine-compare-bounded} and
\ref{perfect-lemma-pseudo-coherent-affine})
to a pseudo-coherent object $K$ of $D(A)$.
Observe that $E_0$ corresponds to $K \otimes_A^\mathbf{L} A/IA$.
Let $\mathfrak q \subset \mathfrak q_0 \subset A$ be the prime
ideals corresponding to $x \leadsto x_0$.
Then $E_x = K_{\mathfrak q}$ and $K_{\mathfrak q}$
is a localization of $K_{\mathfrak q_0}$. Hence it suffices
to show that $K_{\mathfrak q_0}$ has tor amplitude in
$[a_i - d_i, b_i]$ as a complex of $R$-modules.
Let $I \subset \mathfrak p_0 \subset R$ be the prime
ideal corresponding to $f(x_0)$.
Then we have
\begin{align*}
K \otimes_R^\mathbf{L} \kappa(\mathfrak p_0)
& =
(K \otimes_R^\mathbf{L} R/I) \otimes_{R/I}^\mathbf{L}
\kappa(\mathfrak p_0) \\
& =
(K \otimes_A^\mathbf{L} A/IA) \otimes_{R/I}^\mathbf{L} \kappa(\mathfrak p_0)
\end{align*}
the second equality because $R \to A$ is flat.
By our choice of $a_i, b_i$ this complex has cohomology
only in degrees in the interval $[a_i, b_i]$.
Thus we may finally apply
More on Algebra, Lemma
\ref{more-algebra-lemma-lift-from-fibre-relatively-perfect}
to $R \to A$, $\mathfrak q_0$, $\mathfrak p_0$ and $K$
to conclude.
\end{proof}










\section{Contracting rational curves}
\label{section-contracting}

\noindent
In this section we study proper morphisms $f : X \to Y$ whose fibres
have dimension $\leq 1$ having $R^1f_*\mathcal{O}_X = 0$.
To understand the title of this section, please take a look at
Algebraic Curves, Sections
\ref{curves-section-contracting-rational-tails},
\ref{curves-section-contracting-rational-bridges}, and
\ref{curves-section-contracting-to-stable}.

\begin{lemma}
\label{lemma-check-h1-fibre-zero}
Let $f : X \to Y$ be a proper morphism of schemes. Let $y \in Y$
be a point with $\dim(X_y) \leq 1$. If
\begin{enumerate}
\item $R^1f_*\mathcal{O}_X = 0$, or more generally
\item there is a morphism $g : Y' \to Y$ such that $y$ is in the image
of $g$ and such that $R'f'_*\mathcal{O}_{X'} = 0$ where $f' : X' \to Y'$
is the base change of $f$ by $g$.
\end{enumerate}
Then $H^1(X_y, \mathcal{O}_{X_y}) = 0$.
\end{lemma}

\begin{proof}
To prove the lemma we may replace $Y$ by an open neighbourhood of $y$.
Thus we may assume $Y$ is affine
and that all fibres of $f$ have dimension $\leq 1$, see
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}.
In this case $R^1f_*\mathcal{O}_X$ is a quasi-coherent $\mathcal{O}_Y$-module
of finite type and its formation commutes with arbitrary base change, see
Limits, Lemmas \ref{limits-lemma-proper-top-cohomology-finite-type} and
\ref{limits-lemma-higher-direct-images-zero-above-dimension-fibre}.
The lemma follows immediately.
\end{proof}

\begin{lemma}
\label{lemma-h1-fibre-zero}
Let $f : X \to Y$ be a proper morphism of schemes. Let $y \in Y$
be a point with $\dim(X_y) \leq 1$ and $H^1(X_y, \mathcal{O}_{X_y}) = 0$.
Then there is an open neighbourhood $V \subset Y$ of $y$ such that
$R^1f_*\mathcal{O}_X|_V = 0$
and the same is true after base change by any $Y' \to V$.
\end{lemma}

\begin{proof}
To prove the lemma we may replace $Y$ by an open neighbourhood of $y$.
Thus we may assume $Y$ is affine and that all fibres of $f$ have
dimension $\leq 1$, see
Morphisms, Lemma \ref{morphisms-lemma-openness-bounded-dimension-fibres}.
In this case $R^1f_*\mathcal{O}_X$ is a quasi-coherent $\mathcal{O}_Y$-module
of finite type and its formation commutes with arbitrary base change, see
Limits, Lemmas \ref{limits-lemma-proper-top-cohomology-finite-type} and
\ref{limits-lemma-higher-direct-images-zero-above-dimension-fibre}.
Say $Y = \Spec(A)$, $y$ corresponds to the prime $\mathfrak p \subset A$, and
$R^1f_*\mathcal{O}_X$ corresponds to the finite $A$-module $M$.
Then $H^1(X_y, \mathcal{O}_{X_y}) = 0$ means that
$\mathfrak pM_\mathfrak p = M_\mathfrak p$ by the statement
on base change. By Nakayama's lemma
we conclude $M_\mathfrak p = 0$. Since $M$ is finite, we find
an $f \in A$, $f \not \in \mathfrak p$ such that $M_f = 0$.
Thus taking $V$ the principal open $D(f)$ we obtain the desired result.
\end{proof}

\begin{lemma}
\label{lemma-globally-generated-vanishing}
Let $f : X \to Y$ be a proper morphism of schemes such
that $\dim(X_y) \leq 1$ and $H^1(X_y, \mathcal{O}_{X_y}) = 0$
for all $y \in Y$. Let $\mathcal{F}$ be quasi-coherent on $X$. Then
\begin{enumerate}
\item $R^pf_*\mathcal{F} = 0$ for $p > 1$, and
\item $R^1f_*\mathcal{F} = 0$ if there is a surjection
$f^*\mathcal{G} \to \mathcal{F}$ with $\mathcal{G}$ quasi-coherent
on $Y$.
\end{enumerate}
If $Y$ is affine, then we also have
\begin{enumerate}
\item[(3)] $H^p(X, \mathcal{F}) = 0$ for $p \not \in \{0, 1\}$, and
\item[(4)] $H^1(X, \mathcal{F}) = 0$ if $\mathcal{F}$ is globally generated.
\end{enumerate}
\end{lemma}

\begin{proof}
The vanishing in (1) is Limits, Lemma
\ref{limits-lemma-higher-direct-images-zero-above-dimension-fibre}.
To prove (2) we may work locally on $Y$ and assume $Y$ is affine.
Then $R^1f_*\mathcal{F}$ is the quasi-coherent module on $Y$
associated to the module $H^1(X, \mathcal{F})$.
Here we use that $Y$ is affine, quasi-coherence of higher direct
images (Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherence-higher-direct-images}), and
Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherence-higher-direct-images-application}.
Since $Y$ is affine, the quasi-coherent module $\mathcal{G}$
is globally generated, and hence so is $f^*\mathcal{G}$
and $\mathcal{F}$.
In this way we see that (4) implies (2).
Part (3) follows from (1) as well as the remarks on
quasi-coherence of direct images just made. Thus
all that remains is the prove (4).
If $\mathcal{F}$ is globally generated, then there is a surjection
$\bigoplus_{i \in I} \mathcal{O}_X \to \mathcal{F}$. By part (1)
and the long exact sequence of cohomology this
induces a surjection on $H^1$. Since $H^1(X, \mathcal{O}_X) = 0$
because $R^1f_*\mathcal{O}_X = 0$ by
Lemma \ref{lemma-h1-fibre-zero}, and
since $H^1(X, -)$ commutes with direct sums
(Cohomology, Lemma \ref{cohomology-lemma-quasi-separated-cohomology-colimit})
we conclude.
\end{proof}

\begin{lemma}
\label{lemma-h1-fibre-zero-check-h0-kappa}
Let $f : X \to Y$ be a proper morphism of schemes. Assume
\begin{enumerate}
\item for all $y \in Y$ we have $\dim(X_y) \leq 1$ and
$H^1(X_y, \mathcal{O}_{X_y}) = 0$, and
\item $\mathcal{O}_Y \to f_*\mathcal{O}_X$ is surjective.
\end{enumerate}
Then $\mathcal{O}_{Y'} \to f'_*\mathcal{O}_{X'}$ is surjective
for any base change $f' : X' \to Y'$ of $f$.
\end{lemma}

\begin{proof}
We may assume $Y$ and $Y'$ affine. Then we can choose a closed
immersion $Y' \to Y''$ with $Y'' \to Y$ a flat morphism of affines.
By flat base change
(Cohomology of Schemes, Lemma \ref{coherent-lemma-flat-base-change-cohomology})
we see that the result holds for $X'' \to Y''$.
Thus we may assume $Y'$ is a closed subscheme of $Y$.
Let $\mathcal{I} \subset \mathcal{O}_Y$ be the ideal cutting out $Y'$.
Then there is a short exact sequence
$$
0 \to \mathcal{I}\mathcal{O}_X \to
\mathcal{O}_X \to \mathcal{O}_{X'} \to 0
$$
where we view $\mathcal{O}_{X'}$ as a quasi-coherent module on $X$.
By Lemma \ref{lemma-globally-generated-vanishing}
we have $H^1(X, \mathcal{I}\mathcal{O}_X) = 0$.
It follows that
$$
H^0(Y, \mathcal{O}_Y) \to
H^0(Y, f_*\mathcal{O}_X) = H^0(X, \mathcal{O}_X) \to
H^0(X, \mathcal{O}_{X'})
$$
is surjective as desired. The first arrow is surjective as $Y$
is affine and since we assumed $\mathcal{O}_Y \to f_*\mathcal{O}_X$
is surjective and the second by the long exact sequence of
cohomology associated to the short exact sequence above and
the vanishing just proved.
\end{proof}

\begin{lemma}
\label{lemma-h1-fibre-zero-h0-kappa}
Consider a commutative diagram
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
of morphisms of schemes. Let $s \in S$ be a point. Assume
\begin{enumerate}
\item $X \to S$ is locally of finite presentation and flat at
points of $X_s$,
\item $f$ is proper,
\item the fibres of $f_s : X_s \to Y_s$ have dimension $\leq 1$
and $R^1f_{s, *}\mathcal{O}_{X_s} = 0$,
\item $\mathcal{O}_{Y_s} \to f_{s, *}\mathcal{O}_{X_s}$ is surjective.
\end{enumerate}
Then there is an open $Y_s \subset V \subset Y$ such that
(a) $f^{-1}(V)$ is flat over $S$,
(b) $\dim(X_y) \leq 1$ for $y \in V$,
(c) $R^1f_*\mathcal{O}_X|_V = 0$,
(d) $\mathcal{O}_V \to f_*\mathcal{O}_X|_V$
is surjective,
and (b), (c), and (d) remain true after base change by any $Y' \to V$.
\end{lemma}

\begin{proof}
Let $y \in Y$ be a point over $s$.
It suffices to find an open neighbourhood of $y$
with the desired properties. As a first step, we replace $Y$
by the open $V$ found in Lemma \ref{lemma-h1-fibre-zero} so that
$R^1f_*\mathcal{O}_X$ is zero universally (the hypothesis of
the lemma holds by Lemma \ref{lemma-check-h1-fibre-zero}).
We also shrink $Y$ so that all fibres of $f$ have dimension $\leq 1$
(use Morphisms, Lemma
\ref{morphisms-lemma-openness-bounded-dimension-fibres}
and properness of $f$). Thus we may assume we have (b) and (c)
with $V = Y$ and after any base change $Y' \to Y$.
Thus by Lemma \ref{lemma-h1-fibre-zero-check-h0-kappa}
it now suffices to show (d) over $Y$.
We may still shrink $Y$ further; for example, we may and do
assume $Y$ and $S$ are affine.

\medskip\noindent
By Theorem \ref{theorem-openness-flatness}
there is an open subset $U \subset X$ where $X \to S$
is flat which contains $X_s$ by hypothesis.
Then $f(X \setminus U)$ is a closed subset
not containing $y$. Thus after shrinking $Y$
we may assume $X$ is flat over $S$.

\medskip\noindent
Say $S = \Spec(R)$. Choose a closed immersion $Y \to Y'$ where $Y'$
is the spectrum of a polynomial ring $R[x_e; e \in E]$ on a set $E$.
Denote $f' : X \to Y'$ the composition of $f$ with $Y \to Y'$.
Then the hypotheses (1) -- (4) as well as (b) and (c)
hold for $f'$ and $s$. If we we show $\mathcal{O}_{Y'} \to f'_*\mathcal{O}_X$
is surjective in an open neighbourhood of $y$, then the same is true for
$\mathcal{O}_Y \to f_*\mathcal{O}_X$. Thus we may assume $Y$ is
the spectrum of $R[x_e; e \in E]$.

\medskip\noindent
At this point $X$ and $Y$ are flat over $S$. Then $Y_s$ and $X$
are tor independent over $Y$. We urge the reader to find their own
proof, but it also follows from
Lemma \ref{lemma-case-of-tor-independence} applied to the
square with corners $X, Y, S, S$ and its base change by $s \to S$.
Hence
$$
Rf_{s, *}\mathcal{O}_{X_s} = L(Y_s \to Y)^*Rf_*\mathcal{O}_X
$$
by Derived Categories of Schemes, Lemma
\ref{perfect-lemma-compare-base-change}.
Because of the vanishing already established this implies
$f_{s, *}\mathcal{O}_{X_s} = (Y_s \to Y)^*f_*\mathcal{O}_X$.
We conclude that $\mathcal{O}_Y \to f_*\mathcal{O}_X$ is a map of
quasi-coherent $\mathcal{O}_Y$-modules whose pullback
to $Y_s$ is surjective. We claim
$f_*\mathcal{O}_X$ is a finite type $\mathcal{O}_Y$-module.
If true, then the cokernel $\mathcal{F}$ of
$\mathcal{O}_Y \to f_*\mathcal{O}_X$
is a finite type quasi-coherent $\mathcal{O}_Y$-module
such that $\mathcal{F}_y \otimes \kappa(y) = 0$.
By Nakayama's lemma (Algebra, Lemma \ref{algebra-lemma-NAK})
we have $\mathcal{F}_y = 0$. Thus $\mathcal{F}$ is zero
in an open neighbourhood of $y$
(Modules, Lemma \ref{modules-lemma-finite-type-stalk-zero})
and the proof is complete.

\medskip\noindent
Proof of the claim.
For a finite subset $E' \subset E$ set $Y' = \Spec(R[x_e; e \in E'])$.
For large enough $E'$ the morphism $f' : X \to Y \to Y'$ is proper, see
Limits, Lemma \ref{limits-lemma-finite-type-eventually-proper}.
We fix $E'$ and $Y'$ in the following.
Write $R = \colim R_i$ as the colimit of its finite type
$\mathbf{Z}$-subalgebras. Set $S_i = \Spec(R_i)$
and $Y'_i = \Spec(R_i[x_e; e \in E'])$.
For $i$ large enough we can find a diagram
$$
\xymatrix{
X \ar[d] \ar[r]_{f'} & Y' \ar[d] \ar[r] & S \ar[d] \\
X_i \ar[r]^{f'_i} & Y'_i \ar[r] & S_i
}
$$
with cartesian squares such that $X_i$ is flat over $S_i$ and
$X_i \to Y'_i$ is proper. See
Limits, Lemmas \ref{limits-lemma-descend-finite-presentation},
\ref{limits-lemma-descend-flat-finite-presentation}, and
\ref{limits-lemma-eventually-proper}.
The same argument as above shows $Y'$ and $X_i$
are tor independent over $Y'_i$ and hence
$$
R\Gamma(X, \mathcal{O}_X) =
R\Gamma(X_i, \mathcal{O}_{X_i})
\otimes^\mathbf{L}_{R_i[x_e; e \in E']}
R[x_e; e \in E']
$$
by the same reference as above. By Cohomology of Schemes, Lemma
\ref{coherent-lemma-proper-over-affine-cohomology-finite}
the complex $R\Gamma(X_i, \mathcal{O}_{X_i})$ is pseudo-coherent
in the derived category of the Noetherian ring $R_i[x_e; e \in E']$ (see
More on Algebra, Lemma \ref{more-algebra-lemma-Noetherian-pseudo-coherent}).
Hence $R\Gamma(X, \mathcal{O}_X)$ is pseudo-coherent in the derived
category of $R[x_e; e \in E']$, see
More on Algebra, Lemma \ref{more-algebra-lemma-pull-pseudo-coherent}.
Since the only nonvanishing cohomology module
is $H^0(X, \mathcal{O}_X)$ we conclude it is a finite
$R[x_e; e \in E']$-module, see
More on Algebra, Lemma \ref{more-algebra-lemma-n-pseudo-module}.
This concludes the proof.
\end{proof}

\begin{lemma}
\label{lemma-h1-fibre-zero-h0-flat}
Consider a commutative diagram
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
of morphisms of schemes. Assume $X \to S$
is flat, $f$ is proper, $\dim(X_y) \leq 1$ for $y \in Y$, and
$R^1f_*\mathcal{O}_X = 0$. Then $f_*\mathcal{O}_X$
is $S$-flat and formation of $f_*\mathcal{O}_X$ commutes
with arbitrary base change $S' \to S$.
\end{lemma}

\begin{proof}
We may assume $Y$ and $S$ are affine, say $S = \Spec(A)$.
To show the quasi-coherent $\mathcal{O}_Y$-module
$f_*\mathcal{O}_X$ is flat relative to $S$ it suffices
to show that $H^0(X, \mathcal{O}_X)$ is flat over $A$
(some details omitted).
By Lemma \ref{lemma-globally-generated-vanishing} we have
$H^1(X, \mathcal{O}_X \otimes_A M) = 0$ for every $A$-module $M$.
Since also $\mathcal{O}_X$ is flat over $A$ we deduce the functor
$M \mapsto H^0(X, \mathcal{O}_X \otimes_A M)$ is exact.
Moreover, this functor commutes with direct sums by
Cohomology, Lemma \ref{cohomology-lemma-quasi-separated-cohomology-colimit}.
Then it is an exercise to see that
$H^0(X, \mathcal{O}_X \otimes_A M) = M \otimes_A H^0(X, \mathcal{O}_X)$
functorially in $M$ and this gives the desired flatness.
Finally, if $S' \to S$ is a morphism of affines given by
the ring map $A \to A'$, then in the affine case just discussed
we see that
$$
H^0(X \times_S S', \mathcal{O}_{X \times_S S'}) =
H^0(X, \mathcal{O}_X \otimes_A A') = H^0(X, \mathcal{O}_X) \otimes_A A'
$$
This shows that formation of $f_*\mathcal{O}_X$ commutes
with any base change $S' \to S$. Some details omitted.
\end{proof}

\begin{lemma}
\label{lemma-h1-fibre-zero-isom}
Consider a commutative diagram
$$
\xymatrix{
X \ar[rr]_f \ar[rd] & & Y \ar[ld] \\
& S
}
$$
of morphisms of schemes. Let $s \in S$ be a point. Assume
\begin{enumerate}
\item $X \to S$ is locally of finite presentation and flat at
points of $X_s$,
\item $Y \to S$ is locally of finite presentation,
\item $f$ is proper,
\item the fibres of $f_s : X_s \to Y_s$ have dimension $\leq 1$
and $R^1f_{s, *}\mathcal{O}_{X_s} = 0$,
\item $\mathcal{O}_{Y_s} \to f_{s, *}\mathcal{O}_{X_s}$ is an isomorphism.
\end{enumerate}
Then there is an open $Y_s \subset V \subset Y$ such that
(a) $V$ is flat over $S$,
(b) $f^{-1}(V)$ is flat over $S$,
(c) $\dim(X_y) \leq 1$ for $y \in V$,
(d) $R^1f_*\mathcal{O}_X|_V = 0$,
(e) $\mathcal{O}_V \to f_*\mathcal{O}_X|_V$
is an isomorphism, and (a) -- (e)
remain true after base change of $f^{-1}(V) \to V$ by any $S' \to S$.
\end{lemma}

\begin{proof}
Let $y \in Y_s$. We may always replace $Y$ by an open neighbourhood of $y$.
Thus we may assume $Y$ and $S$ affine. We may also assume that
$X$ is flat over $S$, $\dim(X_y) \leq 1$ for $y \in Y$,
$R^1f_*\mathcal{O}_X = 0$ universally, and that
$\mathcal{O}_Y \to f_*\mathcal{O}_X$ is surjective, see
Lemma \ref{lemma-h1-fibre-zero-h0-kappa}. (We won't use all of this.)

\medskip\noindent
Assume $S$ and $Y$ affine.
Write $S = \lim S_i$ as a cofiltered of affine Noetherian schemes $S_i$.
By Limits, Lemma \ref{limits-lemma-descend-finite-presentation}
there exists an element $0 \in I$ and a diagram
$$
\xymatrix{
X_0 \ar[rr]_{f_0} \ar[rd] & & Y_0 \ar[ld] \\
& S_0
}
$$
of finite type morphisms of schemes whose base change to $S$
is the diagram of the lemma. After increasing $0$ we may assume $Y_0$
is affine and $X_0 \to S_0$ proper, see
Limits, Lemmas \ref{limits-lemma-eventually-proper} and
\ref{limits-lemma-limit-affine}.
Let $s_0 \in S_0$ be the image of $s$.
As $Y_s$ is affine, we see that
$R^1f_{s, *}\mathcal{O}_{X_s} = 0$ is equivalent
to $H^1(X_s, \mathcal{O}_{X_s}) = 0$.
Since $X_s$ is the base change of $X_{0, s_0}$ by
the faithfully flat map $\kappa(s_0) \to \kappa(s)$
we see that $H^1(X_{0, s_0}, \mathcal{O}_{X_{0, s_0}}) = 0$
and hence $R^1f_{0, *}\mathcal{O}_{X_{0, s_0}} = 0$.
Similarly, as $\mathcal{O}_{Y_s} \to f_{s, *}\mathcal{O}_{X_s}$
is an isomorphism, so is
$\mathcal{O}_{Y_{0, s_0}} \to f_{0, *}\mathcal{O}_{X_{0, s_0}}$.
Since the dimensions of the fibres of $X_s \to Y_s$ are at most $1$,
the same is true for the morphism $X_{0, s_0} \to Y_{0, s_0}$.
Finally, since $X \to S$ is flat, after increasing $0$
we may assume $X_0$ is flat over $S_0$, see
Limits, Lemma \ref{limits-lemma-descend-flat-finite-presentation}.
Thus it suffices to prove the lemma for
$X_0 \to Y_0 \to S_0$ and the point $s_0$.

\medskip\noindent
Combining the reduction arguments above we reduce to the case where
$S$ and $Y$ affine, $S$ Noetherian, the fibres of $f$ have dimension
$\leq 1$, and $R^1f_*\mathcal{O}_X = 0$ universally.
Let $y \in Y_s$ be a point. Claim:
$$
\mathcal{O}_{Y, y} \longrightarrow (f_*\mathcal{O}_X)_y
$$
is an isomorphism. The claim implies the lemma. Namely, since
$f_*\mathcal{O}_X$ is coherent (Cohomology of Schemes, Proposition
\ref{coherent-proposition-proper-pushforward-coherent})
the claim means we can replace $Y$ by an open neighbourhood of $y$
and obtain an isomorphism $\mathcal{O}_Y \to f_*\mathcal{O}_X$.
Then we conclude that $Y$ is flat over $S$
by Lemma \ref{lemma-h1-fibre-zero-h0-flat}.
Finally, the isomorphism $\mathcal{O}_Y \to f_*\mathcal{O}_X$
remains an isomorphism after any base change $S' \to S$
by the final statement of Lemma \ref{lemma-h1-fibre-zero-h0-flat}.

\medskip\noindent
Proof of the claim. We already know that
$\mathcal{O}_{Y, y} \longrightarrow (f_*\mathcal{O}_X)_y$
is surjective (Lemma \ref{lemma-h1-fibre-zero-h0-kappa})
and that $(f_*\mathcal{O}_X)_y$ is
$\mathcal{O}_{S, s}$-flat (Lemma \ref{lemma-h1-fibre-zero-h0-flat})
and that the induced map
$$
\mathcal{O}_{Y_s, y} =  \mathcal{O}_{Y, y}/\mathfrak m_s\mathcal{O}_{Y, y}
\longrightarrow
(f_*\mathcal{O}_X)_y/\mathfrak m_s (f_*\mathcal{O}_X)_y
\to
(f_{s, *}\mathcal{O}_{X_s})_y
$$
is injective by the assumption in the lemma. Then it follows from
Algebra, Lemma \ref{algebra-lemma-mod-injective}
that $\mathcal{O}_{Y, y} \longrightarrow (f_*\mathcal{O}_X)_y$
is injective as desired.
\end{proof}

\begin{lemma}
\label{lemma-bijection-on-Pic}
Let $f : X \to Y$ be a proper morphism of Noetherian schemes
such that $f_*\mathcal{O}_X = \mathcal{O}_Y$, such that
the fibres of $f$ have dimension $\leq 1$, and such that
$H^1(X_y, \mathcal{O}_{X_y}) = 0$ for $y \in Y$.
Then $f^* : \Pic(Y) \to \Pic(X)$ is a bijection onto
the subgroup of $\mathcal{L} \in \Pic(X)$ with
$\mathcal{L}|_{X_y} \cong \mathcal{O}_{X_y}$
for all $y \in Y$.
\end{lemma}

\begin{proof}
By the projection formula
(Cohomology, Lemma \ref{cohomology-lemma-projection-formula})
we see that $f_*f^*\mathcal{N} \cong \mathcal{N}$ for
$\mathcal{N} \in \Pic(Y)$.
We claim that for $\mathcal{L} \in \Pic(X)$ with
$\mathcal{L}|_{X_y} \cong \mathcal{O}_{X_y}$
for all $y \in Y$ we have $\mathcal{N} = f_*\mathcal{L}$
is invertible and $\mathcal{L} \cong f^*\mathcal{N}$.
This will finish the proof.

\medskip\noindent
The $\mathcal{O}_Y$-module $\mathcal{N} = f_*\mathcal{L}$
is coherent by Cohomology of Schemes, Proposition
\ref{coherent-proposition-proper-pushforward-coherent}.
Thus to see that it is an invertible $\mathcal{O}_Y$-module,
it suffices to check on stalks (Algebra, Lemma
\ref{algebra-lemma-finite-projective}).
Since the map from a Noetherian local ring to its completion
is faithfully flat, it suffices to check the completion
$(f_*\mathcal{L})_y^\wedge$ is free (see
Algebra, Section \ref{algebra-section-completion-noetherian} and
Lemma \ref{algebra-lemma-finite-projective-descends}).
For this we will use the theorem of formal functions as formulated in
Cohomology of Schemes, Lemma \ref{coherent-lemma-formal-functions-stalk}.
Since $f_*\mathcal{O}_X = \mathcal{O}_Y$ and hence
$(f_*\mathcal{O}_X)_y^\wedge \cong \mathcal{O}_{Y, y}^\wedge$,
it suffices to show that $\mathcal{L}|_{X_n} \cong \mathcal{O}_{X_n}$
for each $n$ (compatibly for varying $n$.
By Lemma \ref{lemma-picard-group-first-order-thickening}
we have an exact sequence
$$
H^1(X_y, \mathfrak m_y^n\mathcal{O}_X/\mathfrak m_y^{n + 1}\mathcal{O}_X)
\to \Pic(X_{n + 1}) \to \Pic(X_n)
$$
with notation as in the theorem on formal functions.
Observe that we have a surjection
$$
\mathcal{O}_{X_y}^{\oplus r_n} \cong
\mathfrak m_y^n/\mathfrak m_y^{n + 1} \otimes_{\kappa(y)} \mathcal{O}_{X_y}
\longrightarrow
\mathfrak m_y^n\mathcal{O}_X/\mathfrak m_y^{n + 1}\mathcal{O}_X
$$
for some integers $r_n \geq 0$.
Since $\dim(X_y) \leq 1$ this surjection induces a surjection
on first cohomology groups (by the vanishing of cohomology in degrees $\geq 2$
coming from Cohomology, Proposition
\ref{cohomology-proposition-vanishing-Noetherian}).
Hence the $H^1$ in the sequence is zero and the transition maps
$\Pic(X_{n + 1}) \to \Pic(X_n)$ are injective as desired.

\medskip\noindent
We still have to show that $f^*\mathcal{N} \cong \mathcal{L}$.
This is proved by the same method and we omit the details.
\end{proof}









\section{Affine stratifications}
\label{section-affine-stratifications}

\noindent
This material is taken from \cite{RV}. Please read a little bit
about stratifications in
Topology, Section \ref{topology-section-stratifications}
before reading this section.

\medskip\noindent
If $X$ is a scheme, then a stratification of $X$ usually means a
stratification of the underlying topological space of $X$.
The strata are locally closed subsets. We will view these
strata as reduced locally closed subschemes of $X$ using
Schemes, Remark \ref{schemes-remark-reduced-induced-locally-closed}.

\begin{definition}
\label{definition-affine-stratification}
Let $X$ be a scheme. An {\it affine stratification} is a
locally finite stratification $X = \coprod_{i \in I} X_i$
whose strata $X_i$ are affine and such that
the inclusion morphisms $X_i \to X$ are affine.
\end{definition}

\noindent
The condition that a stratification $X = \coprod X_i$ is locally finite is,
in the presence of the condition that the inclusion morphisms $X_i \to X$
are quasi-compact, equivalent to the condition that the strata are locally
constructible subsets of $X$, see Properties, Lemma
\ref{properties-lemma-stratification-locally-finite-constructible}.

\medskip\noindent
The condition that $X_i \to X$ is an affine morphism is independent
on the scheme structure we put on the locally closed subset $X_i$, see
Lemma \ref{lemma-thicken-property-morphisms}. Moreover,
if $X$ is separated (or more generally has affine diagonal) and
$X = \coprod X_i$ is a locally finite stratification with affine strata,
then the morphisms $X_i \to X$ are affine. See
Morphisms, Lemma \ref{morphisms-lemma-affine-permanence}.
This allows us to disregard the condition of affineness of the
inclusion morphisms $X_i \to X$ in most cases of interest.

\medskip\noindent
We are often interested in the case where the partially ordered index set $I$
of the stratification is finite. Recall that the {\it length} of a
partially ordered set $I$ is the supremum of the lengths $p$ of
chains $i_0 < i_1 < \ldots < i_p$ of elements of $I$.

\begin{lemma}
\label{lemma-improve-stratification}
Let $X$ be a scheme. Let $X = \coprod_{i \in I} X_i$ be a finite
affine stratification. There exists an affine stratification
with index set $\{0, \ldots, n\}$ where $n$ is the length of $I$.
\end{lemma}

\begin{proof}
Recall that we have a partial ordering on $I$ such that
the closure of $X_i$ is contained in $\bigcup_{j \leq i} X_j$
for all $i \in I$.
Let $I' \subset I$ be the set of maximal indices of $I$.
If $i \in I'$, then $X_i$ is open in $X$ because the union of the
closures of the other strata is the complement of $X_i$.
Let $U = \bigcup_{i \in I'} X_i$ viewed as an open subscheme of $X$
so that $U_{red} = \coprod_{i \in I'} X_i$ as schemes.
Then $U$ is an affine scheme by
Schemes, Lemma \ref{schemes-lemma-disjoint-union-affines}
and Lemma \ref{lemma-thickening-affine-scheme}. The morphism $U \to X$
is affine as each $X_i \to X$, $i \in I'$ is affine by the same reasoning
using Lemma \ref{lemma-thicken-property-morphisms}.
The complement $Z = X \setminus U$ endowed with the
reduced induced scheme structure has the affine
stratification $Z = \bigcup_{i \in I \setminus I'} X_i$.
Here we use that a morphism of schemes $T \to Z$ is affine
if and only if the composition $T \to X$ is affine; this follows
from Morphisms, Lemmas \ref{morphisms-lemma-closed-immersion-affine},
\ref{morphisms-lemma-composition-affine}, and
\ref{morphisms-lemma-affine-permanence}.
Observe that the partially ordered set $I \setminus I'$
has length exactly one less than the length of $I$.
Hence by induction we find that $Z$ has an affine
stratification $Z = Z_0 \amalg \ldots \amalg Z_{n - 1}$
with index set $\{1, \ldots, n\}$. Setting $Z_n = U$
we obtain the desired stratification of $X$.
\end{proof}

\noindent
If a scheme $X$ has a finite affine stratification, then
of course $X$ is quasi-compact. A bit less obvious is the
fact that it forces $X$ to be quasi-separated as well.

\begin{lemma}
\label{lemma-qc-affine-stratification}
Let $X$ be a scheme. The following are equivalent
\begin{enumerate}
\item $X$ has a finite affine stratification, and
\item $X$ is quasi-compact and quasi-separated.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $X = \bigcup X_i$ be a finite affine stratification. Since each $X_i$
is affine hence quasi-compact, we conclude that $X$ is quasi-compact.
Let $U, V \subset X$ be affine open. Then $U \cap X_i$ and $V \cap X_i$
are affine open in $X_i$ since $X_i \to X$ is an affine morphism. Hence
$U \cap V \cap X_i$ is an affine open of the affine scheme $X_i$ (see
Schemes, Lemma \ref{schemes-lemma-characterize-separated} for example).
Therefore $U \cap V = \coprod U \cap V \cap X_i$ is quasi-compact
as a finite union of affine strata. We conclude that $X$ is
quasi-separated by Schemes, Lemma
\ref{schemes-lemma-characterize-quasi-separated}.

\medskip\noindent
Assume $X$ is quasi-compact and quasi-separated. We may use the
induction principle of
Cohomology of Schemes, Lemma \ref{coherent-lemma-induction-principle}
to prove the assertion that $X$ has a finite affine stratification.
If $X$ is empty, then it has an empty affine stratification.
If $X$ is nonempty affine then it has an affine stratification
with one stratum. Next, asssume $X = U \cup V$ where $U$ is quasi-compact open,
$V$ is affine open, and we have a finite affine stratifications
$U = \bigcup_{i \in I} U_i$ and $U \cap V = \coprod_{j \in J} W_j$.
Denote $Z = X \setminus V$ and $Z' = X \setminus U$.
Note that $Z$ is closed in $U$ and $Z'$ is closed in $V$.
Observe that $U_i \cap Z$ and $U_i \cap W_j = U_i \times_U W_j$ are affine
schemes affine over $U$. (Hints: use that $U_i \times_U W_j \to W_j$ is
affine as a base change of $U_i \to U$, hence $U_i \cap W_j$ is affine,
hence $U_i \cap W_j \to U_i$ is affine, hence $U_i \cap W_j \to U$ is affine.)
It follows that
$$
U = \coprod\nolimits_{i \in I} (U_i \cap Z) \amalg
\coprod\nolimits_{(i, j) \in I \times J} (U_i \cap W_j)
$$
is a finite affine stratification with partial ordering on
$I \amalg I \times J$ given by $i' \leq (i, j) \Leftrightarrow i' \leq i$
and $(i', j') \leq (i, j) \Leftrightarrow i' \leq i$ and $j' \leq j$.
Observe that $(U_i \cap Z) \times_X V = \emptyset$ and
$(U_i \cap W_j) \times_X V = U_i \cap W_j$ are affine.
Hence the morphisms $U_i \cap Z \to X$ and $U_i \cap W_j \to X$
are affine because we can check affineness of a morphism
locally on the target
(Morphisms, Lemma \ref{morphisms-lemma-characterize-affine})
and we have affineness over both $U$ and $V$.
To finish the proof we take the stratification above
and we add one additional stratum, namely $Z'$,
whose index we add as a minimal element to the partially ordered set.
\end{proof}

\begin{definition}
\label{definition-affine-stratification-number}
Let $X$ be a nonempty quasi-compact and quasi-separated scheme. The
{\it affine stratification number} is the smallest integer $n \geq 0$
such that the following equivalent conditions are satisfied
\begin{enumerate}
\item there exists a finite affine stratification
$X = \coprod_{i \in I} X_i$ where $I$ has length $n$,
\item there exists an affine stratification
$X = X_0 \amalg X_1 \amalg \ldots \amalg X_n$ with
index set $\{0, \ldots, n\}$.
\end{enumerate}
\end{definition}

\noindent
The equivalence of the conditions holds by
Lemma \ref{lemma-improve-stratification}.
The existence of a finite affine stratification
is proven in Lemma \ref{lemma-qc-affine-stratification}.

\begin{lemma}
\label{lemma-affine-stratification-number-bound}
Let $X$ be a separated scheme which has an open covering by
$n + 1$ affines. Then the affine stratification number of $X$
is at most $n$.
\end{lemma}

\begin{proof}
Say $X = U_0 \cup \ldots \cup U_n$ is an affine open covering.
Set
$$
X_i = (U_i \cup \ldots \cup U_n) \setminus
(U_{i + 1} \cup \ldots \cup U_n)
$$
Then $X_i$ is affine as a closed subscheme of $U_i$. The morphism $X_i \to X$
is affine by Morphisms, Lemma \ref{morphisms-lemma-affine-permanence}.
Finally, we have $\overline{X_i} \subset X_i \cup X_{i - 1} \cup \ldots X_0$.
\end{proof}

\begin{lemma}
\label{lemma-affine-stratification-number-bound-Noetherian}
Let $X$ be a Noetherian scheme of dimension $\infty > d \geq 0$.
Then the affine stratification number of $X$ is at most $d$.
\end{lemma}

\begin{proof}
By induction on $d$. If $d = 0$, then $X$ is affine, see
Properties, Lemma \ref{properties-lemma-locally-Noetherian-dimension-0}.
Assume $d > 0$. Let $\eta_1, \ldots, \eta_n$ be the generic points
of the irreducible components of $X$ (Properties, Lemma
\ref{properties-lemma-Noetherian-irreducible-components}).
We can cover $X$ by affine opens containing $\eta_1, \ldots, \eta_n$, see
Properties, Lemma \ref{properties-lemma-point-and-maximal-points-affine}.
Since $X$ is quasi-compact we can find a finite affine open covering
$X = \bigcup_{j = 1, \ldots, m} U_j$ with
$\eta_1, \ldots, \eta_n \in U_j$ for all $j = 1, \ldots, m$.
Choose an affine open $U \subset U_1 \cap \ldots \cap U_m$
containing $\eta_1, \ldots, \eta_n$ (possible by the lemma
already quoted). Then the morphism $U \to X$ is affine
because $U \to U_j$ is affine for all $j$, see
Morphisms, Lemma \ref{morphisms-lemma-characterize-affine}.
Let $Z = X \setminus U$.
By construction $\dim(Z) < \dim(X)$.
By induction hypothesis we can find an
affine stratification $Z = \bigcup_{i \in \{0, \ldots, n\}} Z_i$
of $Z$ with $n \leq \dim(Z)$.
Setting $U = X_{n + 1}$ and $X_i = Z_i$ for $i \leq n$
we conclude.
\end{proof}

\begin{proposition}
\label{proposition-vanishing-affine-stratification-number}
Let $X$ be a nonempty quasi-compact and quasi-separated scheme with
affine stratification number $n$. Then $H^p(X, \mathcal{F}) = 0$, $p > n$
for every quasi-coherent $\mathcal{O}_X$-module $\mathcal{F}$.
\end{proposition}

\begin{proof}
We will prove this by induction on the affine stratification number $n$.
If $n = 0$, then $X$ is affine and the result is
Cohomology of Schemes, Lemma
\ref{coherent-lemma-quasi-coherent-affine-cohomology-zero}.
Assume $n > 0$. By Definition \ref{definition-affine-stratification-number}
there is an affine scheme $U$ and an affine open immersion $j : U \to X$
such that the complement $Z$ has affine stratification number $n - 1$.
As $U$ and $j$ are affine we have $H^p(X, j_*(\mathcal{F}|_U)) = 0$
for $p > 0$, see Cohomology of Schemes, Lemmas
\ref{coherent-lemma-relative-affine-cohomology} and
\ref{coherent-lemma-relative-affine-vanishing}.
Denote $\mathcal{K}$ and $\mathcal{Q}$ the kernel and cokernel
of the map $\mathcal{F} \to j_*(\mathcal{F}|_U)$. Thus we obtain
an exact sequence
$$
0 \to \mathcal{K} \to \mathcal{F} \to j_*(\mathcal{F}|_U)
\to \mathcal{Q} \to 0
$$
of quasi-coherent $\mathcal{O}_X$-modules (see
Schemes, Section \ref{schemes-section-quasi-coherent}).
A standard argument, breaking our exact sequence into short
exact sequences and using the long exact cohomology sequence,
shows it suffices to prove $H^p(X, \mathcal{K}) = 0$
and $H^p(X, \mathcal{Q}) = 0$ for $p \geq n$.
Since $\mathcal{F} \to j_*(\mathcal{F}|_U)$ restricts
to an isomorphism over $U$, we see that $\mathcal{K}$
and $\mathcal{Q}$ are supported on $Z$.
By Properties, Lemma
\ref{properties-lemma-quasi-coherent-colimit-finite-type}
we can write these modules as the filtered colimits of
their finite type quasi-coherent submodules.
Using the fact that cohomology of sheaves on $X$ commutes
with filtered colimits, see
Cohomology, Lemma \ref{cohomology-lemma-quasi-separated-cohomology-colimit},
we conclude it suffices to show that if $\mathcal{G}$
is a finite type quasi-coherent module whose support
is contained in $Z$, then $H^p(X, \mathcal{G}) = 0$ for $p \geq n$.
Let $Z' \subset X$ be the scheme theoretic support of
$\mathcal{G} \oplus \mathcal{O}_Z$; we may and do think
of $\mathcal{G}$ as a quasi-coherent module on $Z'$, see
Morphisms, Section \ref{morphisms-section-support}.
Then $Z'$ and $Z$ have the same underlying topological space
and hence the same affine stratification number, namely $n - 1$.
Hence $H^p(X, \mathcal{G}) = H^p(Z', \mathcal{G})$
(equality by Cohomology of Schemes, Lemma
\ref{coherent-lemma-relative-affine-cohomology})
vanishes for $p \geq n$ by induction hypothesis.
\end{proof}

\begin{example}
\label{example-affine-stratification-number}
Let $k$ be a field and let $X = \mathbf{P}^n_k$ be $n$-dimensional projective
space over $k$. Lemma \ref{lemma-affine-stratification-number-bound}
applies to this by Constructions, Lemma
\ref{constructions-lemma-standard-covering-projective-space}.
Hence the affine stratification number of $\mathbf{P}^n_k$ is
at most $n$. On the other hand, we have nonzero cohomology
in degree $n$ for some quasi-coherent modules on
$\mathbf{P}^n_k$, see
Cohomology of Schemes, Lemma
\ref{coherent-lemma-cohomology-projective-space-over-ring}.
Using Proposition \ref{proposition-vanishing-affine-stratification-number}
we conclude that the affine stratification number of
$\mathbf{P}^n_k$ is equal to $n$.
\end{example}








\section{Universally open morphisms}
\label{section-universally-open}

\noindent
Some material on universally open morphisms.

\begin{lemma}
\label{lemma-test-universally-open}
Let $f : X \to S$ be a morphism of schemes.
The following are equivalent
\begin{enumerate}
\item $f$ is universally open,
\item for every morphism $S' \to S$ which is locally of finite presentation
the base change $X_{S'} \to S'$ is open, and
\item for every $n$ the morphism
$\mathbf{A}^n \times X \to \mathbf{A}^n \times S$
is open.
\end{enumerate}
\end{lemma}

\begin{proof}
It is clear that (1) implies (2) and (2) implies (3).
Let us prove that (3) implies (1).
Suppose that the base change $X_T \to T$ is not open
for some morphism of schemes $g : T \to S$.
Then we can find some affine opens
$V \subset S$, $U \subset X$, $W \subset T$
with $f(U) \subset V$ and $g(W) \subset V$
such that $U \times_V W \to W$ is not open.
If we can show that this implies
$\mathbf{A}^n \times U \to \mathbf{A}^n \times V$
is not open, then $\mathbf{A}^n \times X \to \mathbf{A}^n \times S$
is not open and the proof is complete. This reduces us
to the result proved in the next paragraph.

\medskip\noindent
Let $A \to B$ be a ring map such that $A' \to B' = A' \otimes_A B$
does not induce an open map of spectra for some $A$-algebra $A'$.
As the principal opens give a basis for the topology of $\Spec(B')$
we conclude that the image of $D(g)$ in $\Spec(A')$
is not open for some $g \in B'$. Write
$g = \sum_{i = 1, \ldots, n} a'_i \otimes b_i$
for some $n$, $a'_i \in A'$, and $b_i \in B$.
Consider the element $h = \sum_{i = 1, \ldots, n} x_i b_i$
in $B[x_1, \ldots, x_n]$. Assume that $D(h)$ maps to
an open subset under the morphism
$$
\Spec(B[x_1, \ldots, x_n]) \longrightarrow \Spec(A[x_1, \ldots, x_n])
$$
in order to get a contradiction. Then $D(h)$ would map surjectively
onto a quasi-compact open $U \subset \Spec(A[x_1, \ldots, x_n])$.
Let $A[x_1, \ldots, x_n] \to A'$ be the $A$-algebra homomorphism
sending $x_i$ to $a'_i$. This also induces a $B$-algebra
homomorphism $B[x_1, \ldots, x_n] \to B'$ sending $h$ to $g$.
Since
$$
\xymatrix{
\Spec(B[x_1, \ldots, x_n]) \ar[d] &
\Spec(B') \ar[l] \ar[d] \\
\Spec(A[x_1, \ldots, x_n]) &
\Spec(A') \ar[l]
}
$$
is cartesian the image of $D(g)$ in $\Spec(A')$ is equal to the
inverse image of $U$ in $\Spec(A')$ and hence open which is
the desired contradiction.
\end{proof}

\begin{lemma}
\label{lemma-quasi-finite-Noetherian-universally-open}
Let $f : X \to Y$ be a morphism of schemes. If
\begin{enumerate}
\item $f$ is locally quasi-finite,
\item $Y$ is geometrically unibranch and locally Noetherian, and
\item every irreducible component of $X$ dominates
an irreducible component of $Y$,
\end{enumerate}
then $f$ is universally open.
\end{lemma}

\begin{proof}
For any $n$ the scheme $\mathbf{A}^n \times Y$ is geometrically unibranch
by Lemma \ref{lemma-number-of-branches-and-smooth} and
Properties, Lemma \ref{properties-lemma-number-of-branches-1}. Hence
the hypotheses of the lemma hold for the morphisms
$\mathbf{A}^n \times X \to \mathbf{A}^n \times Y$ for all $n$.
By Lemma \ref{lemma-test-universally-open}
it suffices to prove $f$ is open. By Morphisms, Lemma
\ref{morphisms-lemma-locally-finite-presentation-universally-open}
it suffices to show that generalizations lift along $f$.
Suppose that $y' \leadsto y$ is a specialization of points in
$Y$ and $x \in X$ is a point mapping to $y$.
As in Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}
choose a diagram
$$
\xymatrix{
u \ar[d] & U \ar[d] \ar[r] & X \ar[d] \\
v & V \ar[r] & Y
}
$$
where $(V, v) \to (Y, y)$ is an elementary \'etale neighbourhood,
$U \to V$ is finite, $u$ is the unique point of $U$ mapping to $v$,
$U \subset V \times_Y X$ is open, and $v \mapsto y$ and $u \mapsto x$.
Let $E$ be an irreducible component of $U$ passing through $u$
(there is at least one of these). Since $U \to X$ is \'etale, $E$
maps to an irreducible component of $X$,
which in turn dominates an irreducible component of $Y$ (by assumption).
Since $U \to V$ is finite hence closed, we conclude that
the image $E' \subset V$ of $E$ is an irreducible closed subset
passing through $v$ which dominates an irreducible component of $Y$.
Since $V \to Y$ is \'etale $E'$ must be an irreducible component
of $V$ passing through $v$.
Since $Y$ is geometrically unibranch we see that $E'$ is the unique irreducible
component of $V$ passing through $v$ (Lemma \ref{lemma-nr-branches}).
Since $V$ is locally Noetherian we may after shrinking $V$
assume that $E' = V$ (equality of sets).

\medskip\noindent
Since $V \to Y$ is \'etale we can find a specialization
$v' \leadsto v$ whose image is $y' \leadsto y$.
By the above we can find $u' \in U$ mapping to $v'$.
Then $u' \leadsto u$ because $u$ is the only point of
$U$ mapping to $v$ and $U \to V$ is closed.
Then finally the image $x' \in X$ of $u'$ is a point
specializing to $x$ and mapping to $y'$ and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-characterize-universally-open-finite}
Let $A \to B$ be a ring map. Say $B$ is generated as an $A$-module by
$b_1, \ldots, b_d \in B$. Set $h = \sum x_ib_i \in B[x_1, \ldots, x_d]$.
Then $\Spec(B) \to \Spec(A)$ is universally open if and only if the image of
$D(h)$ in $\Spec(A[x_1, \ldots, x_d])$ is open.
\end{lemma}

\begin{proof}
If $\Spec(B) \to \Spec(A)$ is universally open, then of course
the image of $D(h)$ is open. Conversely, assume the image $U$ of
$D(h)$ is open. Let $A \to A'$ be a ring map. It suffices to show
that the image of any principal open $D(g) \subset \Spec(A' \otimes_A B)$
in $\Spec(A')$ is open. We may write
$g = \sum_{i = 1, \ldots, d} a'_i \otimes b_i$ for some $a'_i \in A'$.
Let $A[x_1, \ldots, x_n] \to A'$ be the $A$-algebra homomorphism
sending $x_i$ to $a'_i$. This also induces a $B$-algebra
homomorphism $B[x_1, \ldots, x_n] \to A' \otimes_A B$ sending $h$ to $g$.
Since
$$
\xymatrix{
\Spec(B[x_1, \ldots, x_n]) \ar[d] &
\Spec(B') \ar[l] \ar[d] \\
\Spec(A[x_1, \ldots, x_n]) &
\Spec(A') \ar[l]
}
$$
is cartesian the image of $D(g)$ in $\Spec(A')$ is equal to the
inverse image of $U$ in $\Spec(A')$ and hence open.
\end{proof}

\begin{lemma}
\label{lemma-descend-quasi-finite-universally-open}
Let $S = \lim S_i$ be a limit of a directed system of schemes
with affine transition morphisms.
Let $0 \in I$ and let $f_0 : X_0 \to Y_0$ be a morphism of schemes over $S_0$.
Assume $S_0$, $X_0$, $Y_0$ are quasi-compact and quasi-separated.
Let $f_i : X_i \to Y_i$ be the base change of $f_0$ to $S_i$ and
let $f : X \to Y$ be the base change of $f_0$ to $S$.
If
\begin{enumerate}
\item $f$ is locally quasi-finite and universally open, and
\item $f_0$ is locally of finite presentation,
\end{enumerate}
then there exists an $i \geq 0$ such that $f_i$ is locally quasi-finite
and universally open.
\end{lemma}

\begin{proof}
By Limits, Lemma \ref{limits-lemma-descend-quasi-finite} after increasing
$0$ we may assume $f_0$ is locally quasi-finite. Let $x \in X$.
By \'etale localization of quasi-finite
morphisms we can find a diagram
$$
\xymatrix{
X \ar[d] & U \ar[l] \ar[d] \\
Y & V \ar[l]
}
$$
where $V \to Y$ is \'etale, $U \subset X_V$ is open, $U \to V$ is finite,
and $x$ is in the image of $U \to X$, see
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}.
After shrinking $V$ we may assume $V$ and $U$ are affine.
Since $X$ is quasi-compact, it follows, by taking a finite disjoint
union of such $V$ and $U$, that we can make a diagram as above
such that $U \to X$ is surjective. By
Limits, Lemmas \ref{limits-lemma-descend-finite-presentation},
\ref{limits-lemma-descend-opens},
\ref{limits-lemma-descend-surjective},
\ref{limits-lemma-descend-finite-finite-presentation},
\ref{limits-lemma-descend-etale}, and
\ref{limits-lemma-limit-affine} after possibly increasing $0$
we may assume we have a diagram
$$
\xymatrix{
X_0 \ar[d] & U_0 \ar[l] \ar[d] \\
Y_0 & V_0 \ar[l]
}
$$
where $V_0$ is affine, $V_0 \to Y_0$ is \'etale,
$U_0 \subset (X_0)_{V_0}$ is open, $U_0 \to V_0$ is finite,
and $U_0 \to X_0$ is surjective. Since $V_i \to Y_i$ is \'etale
and hence universally open, follows that it suffices
to prove that $U_i \to V_i$ is universally open for large
enough $i$. This reduces us to the case discussed in the next
paragraph.

\medskip\noindent
Let $A = \colim A_i$ be a filtered colimit of rings.
Let $A_0 \to B_0$ be a ring map. Set $B = A \otimes_{A_0} B_0$ and
$B_i = A_i \otimes_{A_0} B_0$. Assume $A_0 \to B_0$ is finite,
of finite presentation, and $A \to B$ is universally open.
We have to show that $A_i \to B_i$ is universally open for $i$ large enough.
Pick $b_{0, 1}, \ldots, b_{0, d} \in B_0$ which generate $B_0$
as an $A_0$-module. Set $h_0 = \sum_{j = 1, \ldots, d} x_jb_{0, j}$
in $B_0[x_1, \ldots, x_d]$. Denote $h$, resp.\ $h_i$ the image of $h_0$
in $B[x_1, \ldots, x_d]$, resp.\ $B_i[x_1, \ldots, x_d]$.
The image $U$ of $D(h)$ in $\Spec(A[x_1, \ldots, x_d])$ is open
as $A \to B$ is universally open. Of course $U$ is quasi-compact
as the image of an affine scheme. For $i$ large enough there
is a quasi-compact open $U_i \subset \Spec(A_i[x_1, \ldots, x_d])$
whose inverse image in $\Spec(A[x_1, \ldots, x_d])$ is $U$, see
Limits, Lemma \ref{limits-lemma-descend-opens}.
After increasing $i$ we may assume that $D(h_i)$ maps
into $U_i$; this follows from the same lemma by considering the
pullback of $U_i$ in $D(h_i)$. Finally, for $i$ even larger
the morphism of schemes $D(h_i) \to U_i$ will be surjective
by an application of the already used
Limits, Lemma \ref{limits-lemma-descend-surjective}.
We conclude $A_i \to B_i$ is universally open by
Lemma \ref{lemma-characterize-universally-open-finite}.
\end{proof}

\begin{lemma}
\label{lemma-count-geometric-fibres}
Let $f : X \to Y$ be a locally quasi-finite morphism. Then
\begin{enumerate}
\item the functions $n_{X/Y}$ of
Lemmas \ref{lemma-base-change-fibres-nr-geometrically-irreducible-components}
and \ref{lemma-base-change-fibres-nr-geometrically-connected-components}
agree,
\item if $X$ is quasi-compact, then $n_{X/Y}$ attains a maximum $d < \infty$.
\end{enumerate}
\end{lemma}

\begin{proof}
Agreement of the functions is immediate from the fact that the
(geometric) fibres of a locally quasi-finite morphism are discrete, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-fibres}.
Boundedness follows from
Morphisms, Lemmas \ref{morphisms-lemma-characterize-universally-bounded} and
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}.
\end{proof}

\begin{lemma}
\label{lemma-count-geometric-fibres-universally-open}
Let $f : X \to Y$ be a separated, locally quasi-finite, and universally open
morphism of schemes. Let $n_{X/Y}$ be as in
Lemma \ref{lemma-count-geometric-fibres}.
If $n_{X/Y}(y) \geq d$ for some $y \in Y$ and $d \geq 0$,
then $n_{X/Y} \geq d$ in an open neighbourhood of $y$.
\end{lemma}

\begin{proof}
The question is local on $Y$ hence we may assume $Y$ affine.
Let $K$ be an algebraic closure of the residue field $\kappa(y)$.
Our assumption is that $(X_y)_K$ has $\geq d$ connected components.
Then for a suitable quasi-compact open $X' \subset X$
the scheme $(X'_y)_K$ has $\geq d$ connected components; details omitted.
After replacing $X$ by $X'$ we may assume $X$ is quasi-compact.
Then $f$ is quasi-finite. Let $x_1, \ldots, x_n$ be the points of $X$
lying over $y$. Apply
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}
to get an \'etale neighbourhood $(U, u) \to (Y, y)$ and a decomposition
$$
U \times_Y X =
W \amalg
\ \coprod\nolimits_{i = 1, \ldots, n}
\ \coprod\nolimits_{j = 1, \ldots, m_i}
V_{i, j}
$$
as in locus citatus. Observe that $n_{X/Y}(y) = \sum_i m_i$
in this situation; some details omitted.
Since $f$ is universally open, we see
that $V_{i, j} \to U$ is open for all $i, j$. Hence after shrinking
$U$ we may assume $V_{i, j} \to U$ is surjective
for all $i, j$. This proves that
$n_{U \times_Y X/U} \geq \sum_i m_i = n_{X/Y}(y) \geq d$.
Since the construction of $n_{X/Y}$ is compatible with
base change the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-large-open}
Let $f : X \to Y$ be a separated, locally quasi-finite, and universally open
morphism of schemes. Let $n_{X/Y}$ be as in
Lemma \ref{lemma-count-geometric-fibres}.
If $n_{X/Y}$ attains a maximum $d < \infty$, then the set
$$
Y_d = \{y \in Y \mid n_{X/Y}(y) = d\}
$$
is open in $Y$ and the morphism $f^{-1}(Y_d) \to Y_d$ is finite.
\end{lemma}

\begin{proof}
The openness of $Y_d$ is immediate from
Lemma \ref{lemma-count-geometric-fibres-universally-open}.
To prove finiteness over $Y_d$ we redo the argument of the
proof of that lemma. Namely, let $y \in Y_d$. Then there are
at most $d$ points of $X$ lying over $y$. Say
$x_1, \ldots, x_n$ are the points of $X$
lying over $y$. Apply
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}
to get an \'etale neighbourhood $(U, u) \to (Y, y)$ and a decomposition
$$
U \times_Y X =
W \amalg
\ \coprod\nolimits_{i = 1, \ldots, n}
\ \coprod\nolimits_{j = 1, \ldots, m_i}
V_{i, j}
$$
as in locus citatus. Observe that $d = n_{X/Y}(y) = \sum_i m_i$
in this situation; some details omitted.
Since $f$ is universally open, we see
that $V_{i, j} \to U$ is open for all $i, j$. Hence after shrinking
$U$ we may assume $V_{i, j} \to U$ is surjective
for all $i, j$ and we may assume $U$ maps into $W$.
This proves that $n_{U \times_Y X/U} \geq \sum_i m_i = d$.
Since the construction of $n_{X/Y}$ is compatible with
base change we know that $n_{U \times_Y X/U} = d$. This means that
$W$ has to be empty and we conclude that $U \times_Y X \to U$ is finite.
By Descent, Lemma \ref{descent-lemma-descending-property-finite}
this implies that $X \to Y$ is finite over
the image of the open morphism $U \to Y$. In other words,
we see that $f$ is finite over an open neighbourhood of $y$
as desired.
\end{proof}






\section{Weightings}
\label{section-weightings}

\noindent
The material in this section is taken from \cite[Exposee XVII, 6.2.4]{SGA4}.

\medskip\noindent
Let $\pi : U \to V$ be a locally quasi-finite morphism of schemes with
finite fibres. Given a function $w : U \to \mathbf{Z}$ we define a function
$$
\textstyle{\int}_\pi w : V \longrightarrow \mathbf{Z},\quad
v \longmapsto
\sum\nolimits_{u \in U,\ \pi(u) = v} w(u) [\kappa(u) : \kappa(v)]_s
$$
Note that the field extensions are finite
(Morphisms, Lemma \ref{morphisms-lemma-residue-field-quasi-finite}),
$[\kappa' : \kappa]_s$ is the separable degree
(Fields, Definition \ref{fields-definition-insep-degree}),
and the sum is finite as the fibres of $\pi$ are assumed finite.
Another way to compute the value of $\int_\pi w$ at a point $v \in V$
is as follows.
Choose an algebraically closed field $k$ and a morphism
$\overline{v} : \Spec(k) \to V$ whose image is $v$. Then we have
$$
(\textstyle{\int}_\pi w)(v) =
\sum\nolimits_{\overline{u} \in U_{\overline{v}}} w(\overline{u})
$$
where of course $w(\overline{u})$ denotes the value of $w$ at the
image $u$ of the point $\overline{u}$ under the morphism
$U_{\overline{v}} \to U$.
Note that we may view $\overline{u} \in U_{\overline{v}}$ as morphisms
$\overline{u} : \Spec(k) \to U$ such that
$\pi \circ \overline{u} = \overline{v}$. Namely, since
$U \to V$ is locally quasi-finite with finite fibres,
the scheme $U_{\overline{v}}$ is the spectrum
of a finite dimension algebra over $k$ and all of whose prime ideals
are maximal ideals with residue field $k$. To see that the equality
holds, note that the number of morphisms $\overline{u}$ lying over
a given $u$ is equal to $[\kappa(u) : \kappa(v)]_s$ by
Fields, Lemma \ref{fields-lemma-separable-degree}.

\begin{lemma}
\label{lemma-weighting-check-after-etale-base-change}
Given a cartesian square
$$
\xymatrix{
U \ar[d]_\pi & U' \ar[l]^h \ar[d]^{\pi'} \\
V & V' \ar[l]_g
}
$$
with $\pi$ locally quasi-finite with finite fibres
and a function $w : U \to \mathbf{Z}$
we have $(\int_\pi w) \circ g = \int_{\pi'} (w \circ h)$.
\end{lemma}

\begin{proof}
This follows immediately from the second description of $\int_\pi w$
given above. To prove it from the definition, you use that if
$E/F$ is a finite extension of fields and $F'/F$ is another field extension,
then writing $(E \otimes_F F')_{red} = \prod E'_i$ as a product of fields
finite over $F'$, we have
$$
[E : F]_s = \sum [E'_i : F']_s
$$
To prove this equality pick an algebraically closed field
extension $\Omega/F'$ and observe that
\begin{align*}
[E : F]_s
& =
|\Mor_F(E, \Omega)| \\
& =
|\Mor_{F'}(E \otimes_F F', \Omega)| \\
& =
|\Mor_{F'}((E \otimes_F F')_{red}, \Omega)| \\
& =
\sum |\Mor_{F'}(E'_i, \Omega)| \\
& =
\sum [E'_i : F']_s
\end{align*}
where we have used Fields, Lemma \ref{fields-lemma-separable-degree}.
\end{proof}

\begin{definition}
\label{definition-weighting}
Let $f : X \to Y$ be a locally quasi-finite morphism. A
{\it weighting} or a {\it pond\'eration} of $f$ is a map
$w : X \to \mathbf{Z}$ such that for any diagram
$$
\xymatrix{
X \ar[d]_f & U \ar[l]^h \ar[d]^\pi \\
Y & V \ar[l]_g
}
$$
where $V \to Y$ is \'etale, $U \subset X_V$ is open, and $U \to V$ finite,
the function $\int_\pi (w \circ h)$ is locally constant.
\end{definition}

\noindent
Of course taking $w = 0$ we obtain a weighting of any locally quasi-finite
morphism $f$, albeit not a very interesting one. It will turn out that
{\it positive} weigthings, i.e., $w : X \to \mathbf{Z}_{> 0}$ are the
most interesting ones for various purposes.

\begin{lemma}
\label{lemma-weighting-base-change}
Let $f : X \to Y$ be a locally quasi-finite morphism.
Let $w : X \to \mathbf{Z}$ be a weighting. Let $f' : X' \to Y'$
be the base change of $f$ by a morphism $Y' \to Y$. Then the
composition $w' : X' \to \mathbf{Z}$ of $w$ and the projection $X' \to X$
is a weighting of $f'$.
\end{lemma}

\begin{proof}
Consider a diagram
$$
\xymatrix{
X' \ar[d]_{f'} & U' \ar[l]^{h'} \ar[d]^{\pi'} \\
Y' & V' \ar[l]_{g'}
}
$$
as in Definition \ref{definition-weighting} for the morphism $f'$.
For any $v' \in V'$ we have to show that $\int_{\pi'} (w' \circ h')$ is
constant in an open neighbourhood of $v'$. By
Lemma \ref{lemma-weighting-check-after-etale-base-change}
(and the fact that \'etale morphisms are open)
we may replace $V'$ by any \'etale neighbourhood of $v'$.
After replacing $V'$ by an \'etale neighbourhood of $v'$
we may assume that $U' = U'_1 \amalg \ldots \amalg U'_n$
where each $U'_i$ has a unique point $u'_i$ lying over $v'$
such that $\kappa(u'_i)/\kappa(v')$ is purely inseparable,
see Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}.
Clearly, it suffices to prove that $\int_{U'_i \to V'} w'|_{U'_i}$
is constant in a neighbourhood of $v'$.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
We have $v' \in V'$ and there is a unique point $u'$ of $U'$
lying over $v'$ with $\kappa(u')/\kappa(v')$ purely inseparable.
Denote $x \in X$ and $y \in Y$ the image of $u'$ and $v'$.
We can find an \'etale neighbourhood $(V, v) \to (Y, y)$
and an open $U \subset X_V$ such that $\pi : U \to V$ is finite
and such that there is a unique point $u \in U$ lying over $v$
which maps to $x \in X$ via the projection $h : U \to X$
such that moreover $\kappa(u)/\kappa(v)$ is
purely inseparable. This is possible by the lemma used above.
Consider the morphism
$$
U'' = U \times_X U' \longrightarrow V \times_Y V' = V''
$$
Since $u$ and $u'$ both map to $x \in X$ there is a point
$u'' \in U''$ mapping to $(u, u')$. Denote $v'' \in V''$
the image of $u''$. After replacing $V', v'$ by $V'', v''$ 
we may assume that the composition $V' \to Y' \to Y$ factors
through a map of \'etale neighbourhoods $(V', v') \to (V, v)$
such that the induced morphism $X'_{V'} = X_{V'} \to X_V$ sends
$u'$ to $u$. Inside the base change $X'_{V'} = X_{V'}$ we have
two open subschemes, namely $U'$ and the inverse image $U_{V'}$ of
$U \subset X_V$. By construction both contain a unique point lying
over $v'$, namely $u'$ for both of them.
Thus after shrinking $V'$ we may assume these open subsets
are the same; namely, $U' \setminus (U' \cap U_{V'})$ and
$U_{V'} \setminus (U' \cap U_{V'})$ have
a closed image in $V'$ and these images do not contain $v'$.
Thus $U' = U_{V'}$ and we find a cartesian diagram as in
Lemma \ref{lemma-weighting-check-after-etale-base-change}.
Since $\int_\pi (w \circ h)$ is locally constant
by assumption we conclude.
\end{proof}

\begin{lemma}
\label{lemma-weighting-open}
Let $f : X \to Y$ be a locally quasi-finite morphism. Let
$w : X \to \mathbf{Z}$ be a weighting of $f$. If $X' \subset X$ is open,
then $w|_{X'}$ is a weighting of $f|_{X'} : X' \to Y$.
\end{lemma}

\begin{proof}
Immediate from the definition.
\end{proof}

\begin{lemma}
\label{lemma-weighting-composition}
Let $f : X \to Y$ and $g : Y \to Z$ be locally quasi-finite morphisms.
Let $w_f : X \to \mathbf{Z}$ be a weighting of $f$ and let
$w_g : Y \to \mathbf{Z}$ be a weighting of $g$. Then the function
$$
X \longrightarrow \mathbf{Z},\quad
x \longmapsto w_f(x) w_g(f(x))
$$
is a weighting of $g \circ f$.
\end{lemma}

\begin{proof}
Let us set $w_{g \circ f}(x) = w_f(x) w_g(f(x))$ for $x \in X$.
Consider a diagram
$$
\xymatrix{
X \ar[d]_{g \circ f} & U \ar[l] \ar[d]^\pi \\
Z & W \ar[l]
}
$$
where $W \to Z$ is \'etale, $U \subset X_W$ is open, and $U \to W$ finite.
We have to show that $\int_\pi w_{g \circ f}|_U$ is locally constant.
Choose a point $w \in W$. By
Lemma \ref{lemma-weighting-check-after-etale-base-change}
(and the fact that \'etale morphisms are open) it suffices to show that
$\int_\pi w_{g \circ f}|_U$ is constant after replacing
$(W, w)$ by an \'etale neighbourhood.
After replacing $(W, w)$ by an \'etale neighbourhood we may
assume $U = U_1 \amalg \ldots \amalg U_n$ where each $U_i$
has a unique point $u_i$ lying over $w$ such that
$\kappa(u_i)/\kappa(w)$ is purely inseparable, see
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}.
Clearly, it suffices to show that $\int_{U_i \to W} w_{g \circ f}|_{U_i}$
is constant in an \'etale neighbourhood of $w$.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
We have $w \in W$ and there is a unique point $u \in U$ lying
over $w$ with $\kappa(u)/\kappa(w)$ purely inseparable.
Consider the point $v = f(u) \in Y$. After replacing
$(W, w)$ by an elementary \'etale neighbourhood we may
assume there is an open neighbourhood $V \subset Y_W$
of $v$ such that $V \to W$ is finite, see
Lemma \ref{lemma-etale-makes-quasi-finite-finite-at-point}.
Then $f_W^{-1}(V) \cap U$ is an open neighbourhood of $u$
where $f_W : X_W \to Y_W$ is the base change of $f$ to $W$.
Hence after Zariski shrinking $W$, we may assume $f_W(U) \subset V$.
Thus we obtain morphisms
$$
U \xrightarrow{a} V \xrightarrow{b} W
$$
and $U \to V$ is finite as $V \to W$ is separated (because finite).
Since $w_f$ and $w_g$ are weightings of $f$ and $g$
we see that $\int_a w_f|_U$ is locally constant on $V$ and
$\int_b w_g|_V$ is locally constant on $W$. Thus after shrinking
$W$ one more time we may assume these functions are constant
say with values $n$ and $m$. It follows immediately that
$\int_\pi w_{g \circ f}|_U = \int_{b \circ a} w_{g \circ f}|_U$
is constant with value $nm$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-weighting-universally-open}
Let $f : X \to Y$ be a locally quasi-finite morphism.
Let $w : X \to \mathbf{Z}$ be a weighting. If $w(x) > 0$
for all $x \in X$, then $f$ is universally open.
\end{lemma}

\begin{proof}
Since the property is preserved by base change, see
Lemma \ref{lemma-weighting-base-change}, it suffices
to prove that $f$ is open. Since we may also replace
$X$ by any open of $X$, it suffices to prove that $f(X)$
is open. Let $y \in f(X)$. Choose $x \in X$ with $f(x) = y$.
It suffices to prove that $f(X)$ contains an open neighbourhood
of $y$ and it suffices to do so after replacing $Y$ by an
\'etale neighbourhood of $y$. By \'etale localization of
quasi-finite morphisms, see Section \ref{section-etale-localization},
we may assume
there is an open neighbourhood $U \subset X$ of $x$
such that $\pi = f|_U : U \to Y$ is finite. Then
$\int_\pi w|_U$ is locally constant and has positive value at $y$.
Hence $\pi(U)$ contains an open neighbourhood of $y$
and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-weighting-flat-quasi-finite}
Let $f : X \to Y$ be a morphism of schemes. Assume $f$ is
locally quasi-finite, locally of finite presentation, and flat.
Then there is a positive weighting $w : X \to \mathbf{Z}_{> 0}$ of $f$
given by the rule that sends $x \in X$ lying over $y \in Y$ to
$$
w(x) =
\text{length}_{\mathcal{O}_{X, x}}
(\mathcal{O}_{X, x}/\mathfrak m_y \mathcal{O}_{X, x})
[\kappa(x) : \kappa(y)]_i
$$
where $[\kappa' : \kappa]_i$ is the inseparable degree
(Fields, Definition \ref{fields-definition-insep-degree}).
\end{lemma}

\begin{proof}
Consider a diagram as in Definition \ref{definition-weighting}.
Let $u \in U$ with images $x, y, v$ in $X, Y, V$. Then we claim that
$$
\text{length}_{\mathcal{O}_{X, x}}
(\mathcal{O}_{X, x}/\mathfrak m_y \mathcal{O}_{X, x}) =
\text{length}_{\mathcal{O}_{U, u}}
(\mathcal{O}_{U, u}/\mathfrak m_v \mathcal{O}_{U, u})
$$
and
$$
[\kappa(x) : \kappa(y)]_i =
[\kappa(u) : \kappa(v)]_i
$$
The first equality follows as $\mathcal{O}_{X, x} \to \mathcal{O}_{U, u}$
is a flat local homomorphism such that
$\mathfrak m_y \mathcal{O}_{U, u} = \mathfrak m_v \mathcal{O}_{U, u}$
and $\mathfrak m_x \mathcal{O}_{U, u} = \mathfrak m_u$
(because $\mathcal{O}_{Y, y} \to \mathcal{O}_{V, v}$ and
$\mathcal{O}_{X, x} \to \mathcal{O}_{U, u}$ are unramified)
and hence the equality by Algebra, Lemma \ref{algebra-lemma-pullback-module}.
The second equality follows because $\kappa(v)/\kappa(y)$ is a finite
separable extension and $\kappa(u)$ is a factor of
$\kappa(x) \otimes_{\kappa(y)} \kappa(v)$ and hence the inseparable
degree is unchanged. Having said this, we see that formation
of the function in the lemma commutes with \'etale base change.
This reduces the problem to the discussion of the next paragraph.

\medskip\noindent
Assume that $f$ is a finite, flat morphism of finite presentation.
We have to show that $\int_f w$ is locally constant on $Y$.
In fact, $f$ is finite locally free
(Morphisms, Lemma \ref{morphisms-lemma-finite-flat})
and we will show that $\int_f w$ is equal to the degree of $f$
(which is a locally constant function on $Y$). Namely,
for $y \in Y$ we see that
\begin{align*}
(\textstyle{\int}_f w)(y)
& =
\sum\nolimits_{f(x) = y}
\text{length}_{\mathcal{O}_{X, x}}
(\mathcal{O}_{X, x}/\mathfrak m_y \mathcal{O}_{X, x})
[\kappa(x) : \kappa(y)]_i
[\kappa(x) : \kappa(y)]_s \\
& =
\sum\nolimits_{f(x) = y}
\text{length}_{\mathcal{O}_{X, x}}
(\mathcal{O}_{X, x}/\mathfrak m_y \mathcal{O}_{X, x})
[\kappa(x) : \kappa(y)] \\
& =
\text{length}_{\mathcal{O}_{Y, y}}((f_*\mathcal{O}_X)_y/
\mathfrak m_y (f_*\mathcal{O}_X)_y)
\end{align*}
Last equality by Algebra, Lemma \ref{algebra-lemma-pushdown-module}.
The final number is the rank of $f_*\mathcal{O}_X$ at $y$ as desired.
\end{proof}

\begin{lemma}
\label{lemma-weighting-quasi-finite-Noetherian}
Let $f : X \to Y$ be a morphism of schemes. Assume
\begin{enumerate}
\item $f$ is locally quasi-finite, and
\item $Y$ is geometrically unibranch and locally Noetherian.
\end{enumerate}
Then there is a weighting $w : X \to \mathbf{Z}_{\geq 0}$ given by
the rule that sends $x \in X$ lying over $y \in Y$ to the
``generic separable degree''
of $\mathcal{O}_{X, x}^{sh}$ over $\mathcal{O}_{Y, y}^{sh}$.
\end{lemma}

\begin{proof}
It follows from Algebra, Lemma
\ref{algebra-lemma-quasi-finite-strict-henselization}
that $\mathcal{O}_{Y, y}^{sh} \to \mathcal{O}_{X, x}^{sh}$
is finite. Since $Y$ is geometrically unibranch
there is a unique minimal prime $\mathfrak p$ in
$\mathcal{O}_{Y, y}^{sh}$, see
More on Algebra, Lemma \ref{more-algebra-lemma-geometrically-unibranch}.
Write
$$
(\kappa(\mathfrak p) \otimes_{\mathcal{O}_{Y, y}^{sh}}
\mathcal{O}_{X, x}^{sh})_{red} =
\prod K_i
$$
as a finite product of fields.
We set $w(x) = \sum [K_i : \kappa(\mathfrak p)]_s$.

\medskip\noindent
Since this definition is clearly insensitive to \'etale localization,
in order to show that $w$ is a weighting we reduce to showing that if
$f$ is a finite morphism, then $\int_f w$ is locally constant.
Observe that the value of $\int_f w$ in a generic point $\eta$
of $Y$ is just the number of points of the geometric fibre
$X_{\overline{\eta}}$ of $X \to Y$ over $\eta$. Moreover, since
$Y$ is unibranch a point $y$ of $Y$ is the specialization of a unique
generic point $\eta$. Hence it suffices to show that $(\int_f w)(y)$
is equal to the number of points of $X_{\overline{\eta}}$.
After passing to an affine neighbourhood of $y$ we may assume
$X \to Y$ is given by a finite ring map $A \to B$. Suppose
$\mathcal{O}_{Y, y}^{sh}$ is constructed using a map
$\kappa(y) \to k$ into an algebraically closed field $k$.
Then
$$
\mathcal{O}_{Y, y}^{sh} \otimes_A B =
\prod\nolimits_{f(x) = y}
\prod\nolimits_{\varphi \in \Mor_{\kappa(y)}(\kappa(x), k)}
\mathcal{O}_{X, x}^{sh}
$$
by Algebra, Lemma \ref{algebra-lemma-finite-over-henselian}
and the lemma used above.
Observe that the minimal prime $\mathfrak p$ of $\mathcal{O}_{Y, y}^{sh}$
maps to the prime of $A$ corresponding to $\eta$. Hence we see that
the desired equality holds because the number of points of a geometric
fibre is unchanged by a field extension.
\end{proof}



\section{More on weightings}
\label{section-more-weightings}

\noindent
We prove a few more basic properties of weightings. Allthough
at first it appears that weightings can be very wild, it
actually turns out the condition imposed in
Definition \ref{definition-weighting} is rather strong.

\begin{lemma}
\label{lemma-jumps-w}
Let $f : X \to Y$ be a locally quasi-finite morphism.
Let $w : X \to \mathbf{Z}$ be a weighting of $f$. Then
the level sets of the function $w$ are locally constructible in $X$.
\end{lemma}

\begin{proof}
The question is Zariski local on $X$ and $Y$, hence we may assume
$X$ and $Y$ are affine. (Observe that the restriction of a weighting
to an open is a weighting of the restriction of $f$ to that open.)
By Lemma \ref{lemma-weighting-base-change} after base change we still
have a weighthing. If we can find a surjective morphism
$Y' \to Y$ of finite presentation such that the level sets of
$w$ pull back to locally constructible subsets of $X' = Y' \times_Y X$,
then we conclude by Morphisms, Theorem \ref{morphisms-theorem-chevalley}.
We may choose an immersion $X \to T$ where $T \to Y$ is finite, see
Lemma \ref{lemma-quasi-finite-separated-pass-through-finite}.
By Morphisms, Lemma \ref{morphisms-lemma-massage-finite}
after replacing $Y$ by $Y'$ surjective finite locally free over $Y$,
replacing $X$ by $Y' \times_Y X$ and $T$ by a scheme finite locally
free over $Y'$ containing $Y' \times_Y T$ as a closed subscheme,
we may assume $T$ is finite locally free over $Y$,
contains closed subschemes $T_i$ mapping isomorphically to $Y$
such that $T = \bigcup_{i = 1, \ldots, n} T_i$ (set theoretically).
Observe that for $I \subset \{1, \ldots, n\}$ the intersection
$\bigcap_{i \in I} T_i$ is a constructible closed subset of $T$
(and hence maps to a constructible closed subset of $Y$).

\medskip\noindent
For a disjoint union decomposition
$\{1, \ldots, n\} = I_1 \amalg \ldots \amalg I_r$ with nonempty parts
consider the subset $Y_{I_1, \ldots, I_r} \subset Y$
consisting of points $y \in Y$ such that $T_y = \{x_1, \ldots, x_r\}$
consists of exactly $r$ points with $x_j \in T_i \Leftrightarrow i \in I_j$.
This is a constructible partition of $Y$, hence we may
assume that $Y = Y_{I_1, \ldots, I_r}$ for some
disjoint union decomposition
$\{1, \ldots, n\} = I_1 \amalg \ldots \amalg I_r$.
(You can base change by an affine scheme $Y'$ of finite presentation
over $Y$ such that the image of $Y' \to Y$ is exactly
$Y_{I_1, \ldots, I_r}$, see Algebra, Lemma
\ref{algebra-lemma-constructible-is-image}.)
Thus $T = T(1) \amalg \ldots \amalg T(r)$ with $T(j) = \bigcap_{i \in I_j} T_i$
is a decomposition of $T$ into disjoint closed (and hence open) subsets.
Intersecting with the locally closed subscheme $X$ we obtain an analogous
decomposition $X = X(1) \amalg \ldots \amalg X(r)$ into open and closed parts.
The morphism $X(j) \to Y$ an immersion.
Since $w$ is a weigthing, it follows that $w|_{X(j)}$
is locally constant\footnote{In fact, if $f : X \to Y$ is an
immersion and $w$ is a weighting of $f$, then $f$ restricts to an
open map on the locus where $w$ is nonzero.} and we conclude.
\end{proof}

\begin{lemma}
\label{lemma-jumps-int-w}
Let $f : X \to Y$ be a locally quasi-finite morphism of finite
presentation. Let $w : X \to \mathbf{Z}$ be a weighting of $f$. Then
the level sets of the function $\int_f w$ are locally constructible in $Y$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-weighting-check-after-etale-base-change}
formation of the function $\int_f w$ commutes with arbitrary
base change and by Lemma \ref{lemma-weighting-base-change}
after base change we still have a weighthing.
This means that if we can find $Y' \to Y$
surjective and of finite presentation, then it
suffices to prove the result after base change to $Y'$, see
Morphisms, Theorem \ref{morphisms-theorem-chevalley}.

\medskip\noindent
The question is local on $Y$ hence we may assume $Y$ is affine.
Then $X$ is quasi-compact and quasi-separated
(as $f$ is of finite presentation). Suppose that $X = U \cup V$
are quasi-compact open. Then we have
$$
\textstyle{\int}_f w =
\textstyle{\int}_{f|_U} w|_U +
\textstyle{\int}_{f|_V} w|_V -
\textstyle{\int}_{f|_{U \cap V}} w|_{U \cap V}
$$
Thus if we know the result for $w|_U$, $w|_V$, $w|_{U \cap V}$
then we know the result for $w$. By the induction principle
(Cohomology of Schemes, Lemma \ref{coherent-lemma-induction-principle})
it suffices to prove the lemma when $X$ is affine.

\medskip\noindent
Assume $X$ and $Y$ are affine. We may choose an open immersion
$X \to T$ where $T \to Y$ is finite, see
Lemma \ref{lemma-quasi-finite-separated-pass-through-finite}.
Because we may still base change with a suitable $Y' \to Y$
we can use Morphisms, Lemma \ref{morphisms-lemma-massage-finite}
to reduce to the case where
all residue field extensions induced by the morphism $T \to Y$
(and a foriori induced by $X \to Y$) are trivial.
In this situation $\int_f w$ is just taking the sums
of the values of $w$ in fibres. The level sets of $w$
are locally constructible in $X$ (Lemma \ref{lemma-jumps-w}).
The function $w$ only takes a finite number of values by
Properties, Lemma
\ref{properties-lemma-stratification-locally-finite-constructible}.
Hence we conclude by
Morphisms, Theorem \ref{morphisms-theorem-chevalley}
and some elementary arguments on sums of integers.
\end{proof}

\begin{lemma}
\label{lemma-semicontinuous-w}
Let $f : X \to Y$ be a locally quasi-finite morphism.
Let $w : X \to \mathbf{Z}_{> 0}$ be a positive weighting of $f$.
Then $w$ is upper semi-continuous.
\end{lemma}

\begin{proof}
Let $x \in X$ with image $y \in Y$. Choose an \'etale neighbourhood
$(V, v) \to (Y, y)$ and an open $U \subset X_V$ such that
$\pi : U \to V$ is finite and there is a unique point $u \in U$
mapping to $v$ with $\kappa(u)/\kappa(v)$ purely inseparable.
See Lemma \ref{lemma-etale-makes-quasi-finite-finite-multiple-points-var}.
Then $(\int_\pi w|_U)(v) = w(u)$.
It follows from Definition \ref{definition-weighting}
that after replacing $V$ by a neighbourhood of $v$ we
we have $w|_U(u') \leq w|_U(u) = w(x)$ for all $u' \in U$.
Namely, $w|_U(u')$ occurs as a summand in the expression
for $(\int_\pi w|_U)(\pi(u'))$.
This proves the lemma because the \'etale morphism
$U \to X$ is open.
\end{proof}

\begin{lemma}
\label{lemma-semicontinuous-int-w}
Let $f : X \to Y$ be a separated, locally quasi-finite morphism
with finite fibres.
Let $w : X \to \mathbf{Z}_{> 0}$ be a positive weighting of $f$.
Then $\int_f w$ is lower semi-continuous.
\end{lemma}

\begin{proof}
Let $y \in Y$. Let $x_1, \ldots, x_r \in X$ be the points lying over $y$.
Apply
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}
to get an \'etale neighbourhood $(U, u) \to (Y, y)$ and a decomposition
$$
U \times_Y X =
W \amalg
\ \coprod\nolimits_{i = 1, \ldots, n}
\ \coprod\nolimits_{j = 1, \ldots, m_i}
V_{i, j}
$$
as in locus citatus. Observe that $(\int_f w)(y) = \sum w(v_{i, j})$
where $w(v_{i, j}) = w(x_i)$. Since $\int_{V_{i, j} \to U} w|_{V_{i, j}}$
is locally constant by definition, we may after shrinking $U$
assume these functions are constant with value $w(v_{i, j})$.
We conclude that
$$
\textstyle{\int}_{U \times_Y X \to U} w|_{U \times_Y X} =
\textstyle{\int}_{W \to U} w|_W +
\sum \textstyle{\int}_{V_{i, j} \to U} w|_{V_{i, j}} =
\textstyle{\int}_{W \to U} w|_W + (\int_f w)(y)
$$
This is $\geq (\int_f w)(y)$ and we conclude because $U \to Y$
is open and formation of the integral commutes with base change
(Lemma \ref{lemma-weighting-check-after-etale-base-change}).
\end{proof}

\begin{lemma}
\label{lemma-max-int-w}
Let $f : X \to Y$ be a locally quasi-finite morphism
with $X$ quasi-compact. Let $w : X \to \mathbf{Z}$ be a weighting of $f$.
Then $\int_f w$ attains its maximum.
\end{lemma}

\begin{proof}
It follows from Lemma \ref{lemma-jumps-w} and
Properties, Lemma
\ref{properties-lemma-stratification-locally-finite-constructible}
that $w$ only takes a finite number of values on $X$.
It follows from Morphisms, Lemma
\ref{morphisms-lemma-locally-quasi-finite-qc-source-universally-bounded}
that $X \to Y$ has bounded geometric fibres.
This shows that $\int_f w$ is bounded.
\end{proof}

\begin{lemma}
\label{lemma-max-int-finite}
Let $f : X \to Y$ be a separated, locally quasi-finite morphism.
Let $w : X \to \mathbf{Z}_{> 0}$ be a positive weighting of $f$.
Assume $\int_w f$ attains its maximum $d$ and let $Y_d \subset Y$
be the open set of points $y$ with $(\int_f w)(y) = d$. Then
the morphism $f^{-1}(Y_d) \to Y_d$ is finite.
\end{lemma}

\begin{proof}
Observe that $Y_d$ is open by Lemma \ref{lemma-semicontinuous-int-w}.
Let $y \in Y_d$. Say $x_1, \ldots, x_n$ are the points of $X$
lying over $y$. Apply
Lemma \ref{lemma-etale-splits-off-quasi-finite-part-technical-variant}
to get an \'etale neighbourhood $(U, u) \to (Y, y)$ and a decomposition
$$
U \times_Y X =
W \amalg
\ \coprod\nolimits_{i = 1, \ldots, n}
\ \coprod\nolimits_{j = 1, \ldots, m_i}
V_{i, j}
$$
as in locus citatus. Observe that $d = \sum w(v_{i, j})$ where
$w(v_{i, j}) = w(x_i)$. Since $\int_{V_{i, j} \to U} w|_{V_{i, j}}$
is locally constant by definition, we may after shrinking $U$
assume these functions are constant with value $w(v_{i, j})$.
We conclude that
$$
\textstyle{\int}_{U \times_Y X \to U} w|_{U \times_Y X} =
\textstyle{\int}_{W \to U} w|_W +
\sum \textstyle{\int}_{V_{i, j} \to U} w|_{V_{i, j}} =
\textstyle{\int}_{W \to U} w|_W + (\int_f w)(y)
$$
This is $\geq (\int_f w)(y) = d$ and we conclude that $W$
must be the emptyset. Thus $U \times_Y X \to U$ is finite.
By Descent, Lemma \ref{descent-lemma-descending-property-finite}
this implies that $X \to Y$ is finite over
the image of the open morphism $U \to Y$. In other words,
we see that $f$ is finite over an open neighbourhood of $y$
as desired.
\end{proof}

\begin{lemma}
\label{lemma-open-and-closed-in-finite}
Let $A \to B$ be a ring map which is finite and of finite presentation.
There exists a finitely presented ring map $A \to A_{univ}$
and an idempotent $e_{univ} \in B \otimes_A A_{univ}$
such that for any ring map $A \to A'$ and idempotent $e \in B \otimes_A A'$
there is a ring map $A_{univ} \to A'$ mapping $e_{univ}$ to $e$.
\end{lemma}

\begin{proof}
Choose $b_1, \ldots, b_n \in B$ generating $B$ as an $A$-module.
For each $i$ choose a monic $P_i \in A[x]$ such that $P_i(b_i) = 0$
in $B$, see Algebra, Lemma \ref{algebra-lemma-finite-is-integral}.
Thus $B$ is a quotient of the finite free $A$-algebra
$B' = A[x_1, \ldots, x_n]/(P_1(x_1), \ldots, P_n(x_n))$.
Let $J \subset B'$ be the kernel of the surjection $B' \to B$.
Then $J =(f_1, \ldots, f_m)$ is finitely generated as $B$
is a finitely generated $A$-algebra, see
Algebra, Lemma \ref{algebra-lemma-compose-finite-type}.
Choose an $A$-basis $b'_1, \ldots, b'_N$ of $B'$.
Consider the algebra
$$
A_{univ} = A[z_1, \ldots, z_N, y_1, \ldots, y_m]/I
$$
where $I$ is the ideal generated by the coefficients in
$A[z_1, \ldots, z_n, y_1, \ldots, y_m]$
of the basis elements $b'_1, \ldots, b'_N$ of the expresssion
$$
(\sum z_j b'_j)^2 - \sum z_j b'_j + \sum y_k f_k
$$
in $B'[z_1, \ldots, z_N, y_1, \ldots, y_m]$. By construction
the element $\sum z_j b'_j$ maps to an idempotent $e_{univ}$ in the
algebra $B \otimes_A A_{univ}$. Moreover, if $e \in B \otimes_A A'$
is an idempotent, then we can lift $e$ to an element of the form
$\sum b'_j \otimes a'_j$ in $B' \otimes_A A'$ and we can find
$a''_k \in A'$ such that
$$
(\sum b'_j \otimes a'_j)^2 - \sum b'_j \otimes a'_j + \sum f_k \otimes a''_k
$$
is zero in $B' \otimes_A A'$. Hence we get an $A$-algebra map
$A_{univ} \to A$ sending $z_j$ to $a'_j$ and $y_k$ to $a''_k$
mapping $e_{univ}$ to $e$. This finishes the proof.
\end{proof}

\begin{lemma}
\label{lemma-open-and-closed-in-quasi-finite}
Let $X \to Y$ be a morphism of affine schemes which is quasi-finite and
of finite presentation. There exists a morphism $Y_{univ} \to Y$
of finite presentation and an open subscheme
$U_{univ} \subset Y_{univ} \times_Y X$ such that
$U_{univ} \to Y_{univ}$ is finite with the following property:
given any morphism $Y' \to Y$ of affine schemes
and an open subscheme $U' \subset Y' \times_Y X$
such that $U' \to Y'$ is finite, there exists a morphism
$Y' \to Y_{univ}$ such that the inverse image of $U_{univ}$ is $U'$.
\end{lemma}

\begin{proof}
Recall that a finite type morphism is quasi-finite if and only
if it has relative dimension $0$, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-rel-dimension-0}.
By Lemma \ref{lemma-Noetherian-approximation-dimension-d}
applied with $d = 0$ we reduce to the case where
$X$ and $Y$ are Noetherian. We may choose an open immersion
$X \to X'$ such that $X' \to Y$ is finite, see
Algebra, Lemma \ref{algebra-lemma-quasi-finite-open-integral-closure}.
Note that if we have $Y' \to Y$ and $U'$ as in (2), then
$$
U' \to Y' \times_Y X \to Y' \times_Y X'
$$
is open immersion between schemes finite over $Y'$ and hence
is closed as well. We conclude that $U'$ corresponds to an
idempotent in
$$
\Gamma(Y', \mathcal{O}_{Y'})
\otimes_{\Gamma(Y, \mathcal{O}_Y)}
\Gamma(X', \mathcal{O}_{X'})
$$
whose corresponding open and closed subset is contained in
the open $Y' \times_Y X$. Let $Y'_{univ} \to Y$ and idempotent
$$
e'_{univ} \in
\Gamma(Y_{univ}, \mathcal{O}_{Y_{univ}})
\otimes_{\Gamma(Y, \mathcal{O}_Y)}
\Gamma(X', \mathcal{O}_{X'})
$$
be the pair constructed in Lemma \ref{lemma-open-and-closed-in-finite}
for the ring map $\Gamma(Y, \mathcal{O}_Y) \to \Gamma(X', \mathcal{O}_{X'})$
(here we use that $Y$ is Noetherian to see that $X'$ is of finite presentation
over $Y$). Let $U'_{univ} \subset Y'_{univ} \times_Y X'$ be the corresponding
open and closed subscheme. Then we see that
$$
U'_{univ} \setminus Y'_{univ} \times_Y X
$$
is a closed subset of $U'_{univ}$ and hence has closed image
$T \subset Y'_{univ}$. If we set $Y_{univ} = Y'_{univ} \setminus T$
and $U_{univ}$ the restriction of $U'_{univ}$ to
$Y_{univ} \times_Y X$, then we see that the lemma is true.
\end{proof}

\begin{lemma}
\label{lemma-descend-weighting}
Let $Y = \lim Y_i$ be a directed limit of affine schemes. Let $0 \in I$
and let $f_0 : X_0 \to Y_0$ be a morphism of affine schemes which is
quasi-finite and of finite presentation. Let $f : X  \to Y$
and $f_i : X_i \to Y_i$ for $i \geq 0$ be the base changes of $f_0$.
If $w : X \to \mathbf{Z}$ is a weighting of $f$, then for sufficiently
large $i$ there exists a weighting $w_i : X_i \to \mathbf{Z}$
of $f_i$ whose pullback to $X$ is $w$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-jumps-w} the level sets of $w$ are constructible subsets
$E_k$ of $X$. This implies the function $w$ only takes a finite number
of values by Properties, Lemma
\ref{properties-lemma-stratification-locally-finite-constructible}.
Thus there exists an $i$ such that $E_k$ descends to a construcible
subset $E_{i, k}$ in $X_i$ for all $k$; moreover, we may assume
$X_i = \coprod E_{i, k}$. This follows as the topological space
of $X$ is the limit in the category of topological spaces
of the spectral spaces $X_i$ along a directed system with
spectral transition maps. See
Limits, Section \ref{limits-section-descent}
and
Topology, Section \ref{topology-section-limits-spectral}.
We define $w_i : X_i \to \mathbf{Z}$ such that its level
sets are the constructible sets $E_{i, k}$.

\medskip\noindent
Choose $Y_{i, univ} \to Y_i$ and
$U_{i, univ} \subset Y_{i, univ} \times_{Y_i} X_i$
as in Lemma \ref{lemma-open-and-closed-in-quasi-finite}.
By the universal property of the construction, in order to
show that $w_i$ is a weighting, it would suffice to show
that
$$
\tau_i = \textstyle{\int}_{U_{i, univ} \to Y_{i, univ}} w_i|_{U_{i, univ}}
$$
is locally constant on $Y_{i, univ}$. By Lemma \ref{lemma-jumps-int-w}
this function has constructible level sets but it may
not (yet) be locally constant. Set
$Y_{univ} = Y_{i, univ} \times_{Y_i} Y$
and let $U_{univ} \subset Y_{univ} \times_Y X$
be the inverse image of $U_{i, univ}$.
Then, since the pullback of $w$ to $Y_{univ} \times_Y X$
is a weighting for $Y_{univ} \times_Y X \to Y_{univ}$
(Lemma \ref{lemma-weighting-base-change})
we do have that
$$
\tau = \textstyle{\int}_{U_{univ} \to Y_{univ}} w_i|_{U_{univ}}
$$
is locally constant on $Y_{univ}$. Thus the level sets of
$\tau$ are open and closed. Finally, we have
$Y_{univ} = \lim_{i' \geq i} Y_{i', univ}$
and the level sets of $\tau$ are the inverse limits of the
level sets of $\tau_{i'}$ (similarly defined).
Hence the references above imply that for sufficiently
large $i'$ the level sets of $\tau_{i'}$ are open as well.
For such an index $i'$ we conclude that $w_{i'}$
is a weighting of $f_{i'}$ as desired.
\end{proof}







\section{Weightings and affine stratification numbers}
\label{section-bounds-asn}

\noindent
In this section we give a bound for the affine stratification number of a
scheme which has a certain kind of cover by an affine scheme.

\begin{lemma}
\label{lemma-affineness-of-large-open}
Let $f : X \to Y$ be a morphism of affine schemes which is
quasi-finite and of finite presentation.
Let $w : X \to \mathbf{Z}_{> 0}$ be a postive weighting of $f$.
Let $d < \infty$ be the maximum value of $\int_f w$. The open
$$
Y_d = \{y \in Y \mid (\textstyle{\int}_f w)(y) = d \}
$$
of $Y$ is affine.
\end{lemma}

\begin{proof}
Observe that $\int_f w$ attains its maximum by Lemma \ref{lemma-max-int-w}.
The set $Y_d$ is open by Lemma \ref{lemma-semicontinuous-int-w}.
Thus the statement of the lemma makes sense.

\medskip\noindent
Reduction to the Noetherian case; please skip this paragraph.
Recall that a finite type morphism is quasi-finite if and only
if it has relative dimension $0$, see
Morphisms, Lemma \ref{morphisms-lemma-locally-quasi-finite-rel-dimension-0}.
By Lemma \ref{lemma-Noetherian-approximation-dimension-d}
applied with $d = 0$ we can find a quasi-finite morphism $f_0 : X_0 \to Y_0$
of affine Noetherian schemes and a morphism $Y \to Y_0$ such that $f$
is the base change of $f_0$. Then we can write $Y = \lim Y_i$ as a directed
limit of affine schemes of finite type over $Y_0$, see
Algebra, Lemma \ref{algebra-lemma-ring-colimit-fp}.
By Lemma \ref{lemma-descend-weighting}
we can find an $i$ such that our weighting $w$
descends to a weighting $w_i$ of the base change $f_i : X_i \to Y_i$
of $f_0$. Now if the lemma holds for $f_i, w_i$, then it implies
the lemma for $f$ as formation of $\int_f w$ commutes with base
change, see Lemma \ref{lemma-weighting-check-after-etale-base-change}.

\medskip\noindent
Assume $X$ and $Y$ Noetherian. Let $X' \to Y'$ be the base change of $f$
by a morphism $g : Y' \to Y$. The formation of $\int_f w$ and hence
the open $Y_d$ commute with base change. If $g$ is finite and surjective, then
$Y'_d \to Y_d$ is finite and surjective. In this case proving that
$Y_d$ is affine is equivalent to showing that $Y'_d$ is affine, see
Cohomology of Schemes, Lemma
\ref{coherent-lemma-image-affine-finite-morphism-affine-Noetherian}.

\medskip\noindent
We may choose an immersion $X \to T$ with $T$ finite over $Y$, see Lemma
\ref{lemma-quasi-finite-separated-pass-through-finite}.
We are going to apply Morphisms, Lemma \ref{morphisms-lemma-massage-finite}
to the finite morphism $T \to Y$. This lemma tells us that
there is a finite surjective morphism $Y' \to Y$ such that
$Y' \times_Y T$ is a closed subscheme of a scheme $T'$ finite over $Y'$
which has a special form.
By the discussion in the first paragraph, we may replace $Y$ by $Y'$,
$T$ by $T'$, and $X$ by $Y' \times_Y X$.
Thus we may assume there is an immersion $X \to T$ (not necessarily
open or closed) and closed subschemes
$T_i \subset T$, $i = 1, \ldots, n$ where
\begin{enumerate}
\item $T \to Y$ is finite (and locally free),
\item $T_i \to Y$ is an isomorphism, and
\item $T = \bigcup_{i = 1, \ldots, n} T_i$ set theoretically.
\end{enumerate}
Let $Y' = \coprod Y_k$ be the disjoint union of the irreducible
components of $Y$ (viewed as integral closed subschemes of $Y$).
Then we may base change once more by $Y' \to Y$; here we
are using that $Y$ is Noetherian. Thus we may in
addition assume $Y$ is integral and Noetherian.

\medskip\noindent
We also may and do assume that $T_i \not = T_j$ if $i \not = j$ by
removing repeats. Since $Y$ and hence all $T_i$ are integral, this
means that if $T_i$ and $T_j$ intersect, then they intersect in a
closed subset which maps to a proper closed subset of $Y$.

\medskip\noindent
Observe that $V_i = X \cap T_i$ is a locally closed subset
which is in addition a closed subscheme of $X$ hence affine.
Let $\eta \in Y$ and $\eta_i \in T_i$ be the generic points.
If $\eta \not \in Y_d$, then $Y_d = \emptyset$ and we're done.
Assume $\eta \in Y_d$. Denote $I \in \{1, \ldots, n\}$
the subset of indices $i$ such that $\eta_i \in V_i$.
For $i \in I$ the locally closed subset $V_i \subset T_i$
contains the generic point of the irreducible space $T_i$
and hence is open. On the other hand, since $f$ is open
(Lemma \ref{lemma-weighting-universally-open}),
for any $x \in X$ we can find an $i \in I$ and a specialization
$\eta_i \leadsto x$. It follows that $x \in T_i$ and hence
$x \in V_i$. In other words, we see that $X = \bigcup_{i \in I} V_i$
set theoretically.
We claim that $Y_d = \bigcap_{i \in I} \Im(V_i \to Y)$; this will
finish the proof as the intersection of affine opens
$\Im(V_i \to Y)$ of $Y$ is affine.

\medskip\noindent
For $y \in Y$ let $f^{-1}(\{y\}) = \{x_1, \ldots, x_r\}$ in $X$.
For each $i \in I$ there is at most one $j(i) \in \{1, \ldots, x_r\}$
such that $\eta_i \leadsto x_{j(i)}$. In fact, $j(i)$ exists and is
equal to $j$ if and only if $x_j \in V_i$. If $i \in I$ is such that
$j = j(i)$ exists, then $V_i \to Y$ is an isomorphism in a neighbourhood
of $x_j \mapsto y$. Hence $\bigcup_{i \in I,\ j(i) = j} V_i \to Y$
is finite after replacing source and target by neighbourhoods of
$x_j \mapsto y$. Thus the definition of a weighting tells us that
$w(x_j) = \sum_{i \in I,\ j(i) = j} w(\eta_i)$.
Thus we see that
$$
(\textstyle{\int}_f w)(\eta) =
\sum\nolimits_{i \in I} w(\eta_i) \geq
\sum\nolimits_{j(i)\text{ exists}} w(\eta_i) =
\sum\nolimits_j w(x_j) = (\textstyle{\int}_f w)(y)
$$
Thus equality holds if and only if $y$ is contained in
$\bigcap_{i \in I} \Im(V_i \to Y)$ which is what we wanted to show.
\end{proof}

\begin{proposition}
\label{proposition-asn-weighting}
Let $f : X \to Y$ be a surjective quasi-finite morphism of schemes.
Let $w : X \to \mathbf{Z}_{> 0}$ be a positive weighting of $f$.
Assume $X$ affine and $Y$ separated\footnote{It suffices if the
diagonal of $Y$ is affine.}. Then the affine stratification
number of $Y$ is at most the number of distinct values of $\int_f w$.
\end{proposition}

\begin{proof}
Note that since $Y$ is separated, the morphism $X \to Y$ is affine
(Morphisms, Lemma \ref{morphisms-lemma-affine-permanence}).
The function $\int_f w$ attains its maximum $d$ by
Lemma \ref{lemma-max-int-w}. We will use induction on $d$.
Consider the open subscheme $Y_d = \{y \in Y \mid (\int_f w)(y) = d\}$
of $Y$ and recall that $f^{-1}(Y_d) \to Y_d$ is finite, see
Lemma \ref{lemma-max-int-finite}.
By Lemma \ref{lemma-affineness-of-large-open}
for every affine open $W \subset Y$ we have that $Y_d \cap W$ is affine
(this uses that $W \times_Y X$ is affine, being affine over $X$).
Hence $Y_d \to Y$ is an affine morphism of schemes. We
conclude that $f^{-1}(Y_d) = Y_d \times_Y X$ is
an affine scheme being affine over $X$.
Then $f^{-1}(Y_d) \to Y_d$ is surjective and
hence $Y_d$ is affine by Limits, Lemma \ref{limits-lemma-affine}.
Set $X' = X \setminus f^{-1}(Y_d)$ and $Y' = Y \setminus Y_d$
viewed as closed subschemes of $X$ and $Y$.
Since $X'$ is closed in $X$ it is affine. Since
$Y'$ is closed in $Y$ it is separated.
The morphism $f' : X' \to Y'$ is surjective and
$w$ induces a weighting $w'$ of $f'$, see
Lemma \ref{lemma-weighting-base-change}.
By induction $Y'$ has an affine stratification of
length $\leq$ the number of distinct values of
$\int_{f'} w'$ and the proof is complete.
\end{proof}









\section{Completely decomposed morphisms}
\label{section-completely-decomposed}

\noindent
Nishnevich studied the notion of a completely decomposed family
of \'etale morphisms, in order to define what is now called the
Nishnevich topology, see for example \cite{Nishnevich}.

\begin{definition}
\label{definition-cd-morphism}
A morphism $f : X \to Y$ of schemes is said to be
{\it completely decomposed}\footnote{This may be nonstandard terminology.}
if for all points $y \in Y$ there
is a point $x \in X$ with $f(x) = y$ such that the field
extension $\kappa(x)/\kappa(y)$ is trivial.
A family of morphisms $\{f_i : X_i \to Y\}_{i \in I}$ of
schemes with fixed target is said to be {\it completely decomposed}
if $\coprod f_i : \coprod Y_i \to X$ is completely decomposed.
\end{definition}

\noindent
We start with some basic lemmas.

\begin{lemma}
\label{lemma-composition-cd}
The composition of two completely decomposed morphisms of schemes
is completely decomposed.
If $\{f_i : X_i \to Y\}_{i \in I}$ is completely decomposed
and for each $i$ we have a family $\{X_{ij} \to X_i\}_{j \in J_i}$
which is completely decomposed, then the family
$\{X_{ij} \to Y\}_{i \in I, j \in J_i}$ is completely decomposed.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-base-change-cd}
The base change of a completely decomposed morphism of schemes
is completely decomposed.
If $\{f_i : X_i \to Y\}_{i \in I}$ is completely decomposed
and $Y' \to Y$ is a morphism of schemes, then
$\{X_i \times_Y Y' \to Y'\}_{i \in I}$ is completely
decomposed.
\end{lemma}

\begin{proof}
Let $f : X \to Y$ and $g : Y' \to Y$ be morphisms of schemes.
Let $y' \in Y'$ be a point with image $y = g(y')$ in $Y$.
If $x \in X$ is a point such that $f(x) = y$ and $\kappa(x) = \kappa(y)$,
then there exists a unique point $x' \in X' = X \times_Y Y'$
which maps to $y'$ in $Y'$ and to $x$ in $X$ and moreover
$\kappa(x') = \kappa(y')$, see
Schemes, Lemma \ref{schemes-lemma-points-fibre-product}.
From this fact the lemma follows easily; we omit the details.
\end{proof}

\begin{lemma}
\label{lemma-decompose}
\begin{reference}
\cite[Lemma 2.1.2]{EHIK}
\end{reference}
Let $f : X \to Y$ be a morphism of schemes. Assume
$f$ is completely decomposed,
$f$ is locally of finite presentation, and
$Y$ is quasi-compact and quasi-separated.
Then there exist $n \geq 0$ and morphisms
$Z_i \to Y$, $i = 1, \ldots, n$ with the following properties
\begin{enumerate}
\item $\coprod Z_i \to Y$ is surjective,
\item $Z_i \to Y$ is an immersion for all $i$,
\item $Z_i \to Y$ is of finite presentation for all $i$, and
\item the base change $X \times_Y Z_i \to Z_i$ has a section
for all $i$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $y \in Y$. By assumption there is a morphism
$\sigma : \Spec(\kappa(y)) \to X$ over $Y$. We can write $\Spec(\kappa(y))$
as a directed limit of affine schemes $Z$ over $Y$ such that
$Z \to Y$ is an immersion of finite presentation.
Namely, choose an affine open $y \in \Spec(A) \subset Y$
and say $y$ corresponds to the prime ideal $\mathfrak p$ of $A$.
Then $\kappa(\mathfrak p)$ is the filtered colimit of
the rings $(A/I)_f$ where $I \subset \mathfrak p$ is a finitely
generated ideal and $f \in A$, $f \not \in \mathfrak p$.
The morphisms $Z = \Spec((A/I)_f) \to Y$ are immersions of
finite presentation; quasi-compactness of $Z \to Y$
follows as $Y$ is quasi-separated, see
Schemes, Lemma \ref{schemes-lemma-quasi-compact-permanence}.
By Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}
for some such $Z$ there is a morphism $\sigma' : Z \to X$ over $Y$
agreeing with $\sigma$ on the spectrum of $\kappa(\mathfrak p)$.
Since $\sigma'$ is a morphism over $Y$, we obtain a section
of the projection $X \times_Y Z \to Z$

\medskip\noindent
We conclude that $Y$ is the union of the images of immersions
$Z \to Y$ of finite presentation such that $X \times_Y Z \to Z$
has a section. Since the image of $Z \to Y$ is constructible
(Morphisms, Lemma \ref{morphisms-lemma-chevalley})
and since $Y$ is compact in the constructible topology
(Properties, Lemma
\ref{properties-lemma-quasi-compact-quasi-separated-spectral} and
Topology, Lemma \ref{topology-lemma-constructible-hausdorff-quasi-compact}),
we see that a finite number of these suffice.
\end{proof}

\begin{lemma}
\label{lemma-descend-cd}
Let $S = \lim_{\lambda \in \Lambda} S_\lambda$
be a limit of a directed system of schemes with affine transition morphisms.
Let $0 \in \Lambda$ and let $f_0 : X_0 \to Y_0$
be a morphism of schemes over $S_0$.
For $\lambda \geq 0$ let $f_\lambda : X_\lambda \to Y_\lambda$
be the base change of $f_0$ to $S_\lambda$ and
let $f : X \to Y$ be the base change of $f_0$ to $S$. If
\begin{enumerate}
\item $f$ is completely decomposed,
\item $Y_0$ is quasi-compact and quasi-separated, and
\item $f_0$ is locally of finite presentation,
\end{enumerate}
then there exists an $\lambda \geq 0$ such that $f_\lambda$
is completely decomposed.
\end{lemma}

\begin{proof}
Since $Y_0$ is quasi-compact and quasi-separated, the scheme $Y$,
which is affine over $Y_0$, is quasi-compact and quasi-separated.
Choose $n \geq 0$ and $Z_i \to Y$, $i = 1, \ldots, n$ as in
Lemma \ref{lemma-decompose}. Denote $\sigma_i : Z_i \to X$
morphisms over $Y$ which exist by our choice of $Z_i$.
After increasing $0 \in \Lambda$ we may assume there exist
morphisms $Z_{i, 0} \to Y_0$ of finite presentation
whose base changes to $S$ are the morphisms $Z_i \to Y$, see
Limits, Lemma \ref{limits-lemma-descend-finite-presentation}.
By Limits, Lemma \ref{limits-lemma-descend-immersion}
we may assume, after possibly increasing $0$, that $Z_{i, 0} \to Y_0$
is an immersion. Since $\coprod Z_i \to Y$ is surjective, we may assume,
after possibly increasing $0$, that
$\coprod Z_{i, 0} \to Y_0$ is surjective, see
Limits, Lemma \ref{limits-lemma-descend-surjective}. Observe that
$Z_i = \lim_{\lambda \geq 0} Z_{i, \lambda}$
where $Z_{i, \lambda} = Y_\lambda \times_{Y_0} Z_{i, 0}$.
Let us view the compositions
$$
Z_i \xrightarrow{\sigma_i} X \to X_0
$$
as morphisms over $Y_0$. Since $f_0$ is locally of finite
presentation by Limits, Proposition
\ref{limits-proposition-characterize-locally-finite-presentation}
we can find a $\lambda \geq 0$ such that there exist
morphisms $\sigma'_{i, \lambda} : Z_{i, \lambda} \to X_0$
over $Y_0$ whose precomposition with $Z_i \to Z_{i, \lambda}$
are the displayed arrows. Of course, then $\sigma'_{i, \lambda}$
determines a morphism $\sigma_{i, \lambda} : Z_{i, \lambda} \to
X_\lambda = X_0 \times_{Y_0} Y_\lambda$ over $Y_\lambda$.
Since $\coprod Z_{i, \lambda} \to Y_\lambda$ is surjective
we conclude that $X_\lambda \to Y_\lambda$ is completely decomposed.
\end{proof}




\section{Families of ample invertible modules}
\label{section-families-ample-invertible-modules}

\noindent
We continue the discussion from
Morphisms, Section \ref{morphisms-section-families-ample-invertible-modules}.

\begin{lemma}
\label{lemma-ample-family-ample-relative}
Let $f : X \to Y$ be a morphism of schemes. Assume
\begin{enumerate}
\item $Y$ has an ample family of invertible modules,
\item there exists an $f$-ample invertible module on $X$.
\end{enumerate}
Then $X$ has an ample family of invertible modules.
\end{lemma}

\begin{proof}
Let $\mathcal{L}$ be an $f$-ample invertible module on $X$.
This in particular implies that $f$ is quasi-compact, see
Morphisms, Definition \ref{morphisms-definition-relatively-ample}.
Since $Y$ is quasi-compact by Morphisms, Definition
\ref{morphisms-definition-family-ample-invertible-modules}
we see that $X$ is quasi-compact (and hence $X$ itself satisfies the
first condition of  Morphisms, Definition
\ref{morphisms-definition-family-ample-invertible-modules}).
Let $x \in X$ with image $y \in Y$. By assumption (2) we can
find an invertible $\mathcal{O}_Y$-module $\mathcal{N}$ and a section
$t \in \Gamma(Y, \mathcal{N})$ such that the locus $Y_t$ where $t$
does not vanish is affine. Then $\mathcal{L}$ is ample over
$f^{-1}(Y_t) = X_{f^*t}$ and hence we can find a section
$s \in \Gamma(X_{f^*t}, \mathcal{L})$ such that $(X_{f^*t})_s$ is affine
and contains $x$. By
Properties, Lemma \ref{properties-lemma-invert-s-sections}
for some $n \geq 0$ the product $(f^*t)^n s$ extends to a section
$s' \in \Gamma(X, f^*\mathcal{N}^{\otimes n} \otimes \mathcal{L})$.
Then finally the section $s'' = f^* ts'$ of
$f^*\mathcal{N}^{\otimes n + 1} \otimes \mathcal{L}$
vanishes at every point of $X \setminus X_{f^*t}$ hence
we see that $X_{s''} = (X_{f^*t})_s$ is affine as desired.
\end{proof}

\begin{lemma}
\label{lemma-resolution-property-goes-up-affine}
Let $f : X \to Y$ be an affine or quasi-affine morphism of schemes.
If $Y$ has an ample family of invertible modules, so does $X$.
\end{lemma}

\begin{proof}
By Morphisms, Lemma \ref{morphisms-lemma-quasi-affine-O-ample}
this is a special case of
Lemma \ref{lemma-ample-family-ample-relative}.
\end{proof}






\section{Blowing up and ample families of invertible modules}
\label{section-ample-family-by-blowing-up}

\noindent
We prove a result from \cite{Gross-thesis}.

\begin{lemma}
\label{lemma-get-ample-family}
Let $X$ be a scheme. Suppose given effective Cartier divisors
$D_1, \ldots, D_m$ on $X$ and invertible modules
$\mathcal{L}_1, \ldots, \mathcal{L}_m$ such that
$\bigcap D_i = \emptyset$ and $\mathcal{L}_i|_{X \setminus D_i}$
is ample. Then $X$ has an ample family of invertible modules.
\end{lemma}

\begin{proof}
Let $x \in X$. Choose an index $i \in \{1, \ldots, m\}$
such that $x \not \in D_i$. Set $U_i = X \setminus D_i$.
Since $\mathcal{L}_i|_{U_i}$ we can find an $n \geq 1$ and
a section $s \in \Gamma(U_i, \mathcal{L}_i^{\otimes n})$
such that the locus $(U_i)_s$ where $s$ doesn't vanish is affine
(Properties, Definition \ref{properties-definition-ample}).
Since $U_i$ is the locus where the canonical section
$1 \in \mathcal{O}_X(D_i)$ doesn't vanish, we see from
Properties, Lemma \ref{properties-lemma-invert-s-sections}
there exists an $N \geq 0$ such that $s$ extends to a section
$$
s' \in \Gamma(X, \mathcal{L}_i^{\otimes n} \otimes_{\mathcal{O}_X}
\mathcal{O}_X(N D_i))
$$
After replacing $N$ by $N + 1$ we see that $s'$ vanishes at every
point of $D_i$ and hence that $X_{s'} = (U_i)_s$ is affine.
This proves that $X$ has an ample family of invertible modules, see
Morphisms, Definition
\ref{morphisms-definition-family-ample-invertible-modules}.
\end{proof}

\begin{lemma}
\label{lemma-blow-up-ample-family}
\begin{reference}
\cite[Proposition 1.3.1]{Gross-thesis}
\end{reference}
Let $X$ be a quasi-compact and quasi-separated scheme with finitely
many irreducible components. There exists a quasi-compact dense open
$U \subset X$ and a $U$-admissible blowing up $X' \to X$ such that the
scheme $X'$ has an ample family of invertible modules.
\end{lemma}

\begin{proof}
Let $\eta_1, \ldots, \eta_n \in X$ be the generic points of the
irreducible components of $X$. By
Properties, Lemma \ref{properties-lemma-point-and-maximal-points-affine}
and the fact that $X$ is quasi-compact we can find a finite affine
open covering $X = U_1 \cup \ldots \cup U_m$ such that
each $U_i$ contains $\eta_1, \ldots, \eta_n$. In particular
the quasi-compact open subset $U = U_1 \cap \ldots \cap U_m$ is dense in $X$.
Let $\mathcal{I}_i \subset \mathcal{O}_X$ be a finite type quasi-coherent
ideal sheaf such that $U_i = X \setminus Z_i$ where $Z_i = V(\mathcal{I}_i)$,
see Properties, Lemma \ref{properties-lemma-quasi-coherent-finite-type-ideals}.
Let
$$
f : X' \longrightarrow X
$$
be the blowing up of $X$ in the ideal sheaf
$\mathcal{I} = \mathcal{I}_1 \cdots \mathcal{I}_m$.
Note that $f$ is a $U$-admissible blowing up as $V(\mathcal{I})$
is (set theoretically) the union of the $Z_i$ which are disjoint from $U$.
Also, $f$ is a projective morphism and
$\mathcal{O}_{X'}(1)$ is $f$-relatively ample, see
Divisors, Lemma \ref{divisors-lemma-blowing-up-projective}.
By Divisors, Lemma \ref{divisors-lemma-blowing-up-two-ideals}
for each $i$ the morphism $f'$ factors as $X' \to X'_i \to X$
where $X'_i \to X$ is the blowing up in $\mathcal{I}_i$
and $X' \to X'_i$ is another blowing up (namely in the pullback
of the products of the ideals $\mathcal{I}_j$ omitting $\mathcal{I}_i$).
It follows from this that $D_i = f^{-1}(Z_i) \subset X'$ is an effective
Cartier divisor, see
Divisors, Lemmas \ref{divisors-lemma-blow-up-pullback-effective-Cartier} and
\ref{divisors-lemma-blowing-up-gives-effective-Cartier-divisor}.
We have $X' \setminus D_i = f^{-1}(U_i)$. As $\mathcal{O}_{X'}(1)$ is
$f$-ample, the restriction of
$\mathcal{O}_{X'}(1)$ to $X' \setminus D_i$ is ample. It follows from
Lemma \ref{lemma-get-ample-family}
that $X'$ has an ample family of invertible modules.
\end{proof}

\begin{proposition}
\label{proposition-envelope-with-resolution-property}
Let $X$ be a quasi-compact and quasi-separated scheme. There exists a
morphism $f : Y \to X$ which is of finite presentation, proper, and
completely decomposed (Definition \ref{definition-cd-morphism})
such that the scheme $Y$ has an ample family of invertible modules.
\end{proposition}

\begin{proof}
By Limits, Proposition \ref{limits-proposition-approximate}
there exists an affine morphism $X \to X_0$ where $X_0$
is a scheme of finite type over $\mathbf{Z}$. Below we produce
a morphism $Y_0 \to X_0$ with all the desired properties.
Then setting $Y = X \times_{X_0} Y_0$ and $f$ equal to
the projection $f : Y \to X$ we conclude.
To see this observe that $f$ is of finite presentation
(Morphisms, Lemma \ref{morphisms-lemma-base-change-finite-presentation}),
$f$ is proper
(Morphisms, Lemma \ref{morphisms-lemma-base-change-proper}),
$f$ is completely decomposed
(Lemma \ref{lemma-base-change-cd}). Finally, since $Y \to Y_0$ is
affine (as the base change of $X \to X_0$) we see that $Y$ has
an ample family of invertible modules by
Lemma \ref{lemma-resolution-property-goes-up-affine}.
This reduces us to the case discussed in the next paragraph.

\medskip\noindent
Assume $X$ is of finite type over $\mathbf{Z}$. In particular
$\dim(X) < \infty$. We will argue by induction on $\dim(X)$.
If $\dim(X) = 0$, then $X$ is affine and has the resolution property.
In general, there exists a dense open $U \subset X$ and a
$U$-admissible blowing up $X' \to X$ such that $X'$ has
an ample family of invertible modules, see
Lemma \ref{lemma-blow-up-ample-family}.
Since $f : X' \to X$ is an isomorphism over $U$
we see that every point of $U$ lifts to a point of $X'$
with the same residue field.
Let $Z = X \setminus U$ with the reduced induced scheme structure.
Then $\dim(Z) < \dim(X)$ as $U$ is dense in $X$ (see above).
By induction we find a proper, completely decomposed
morphism $W \to Z$ such that $W$ has an ample family of invertible
modules. Then it follows that $Y = X' \amalg W \to X$ is the desired
morphism.
\end{proof}






\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}
